Jupyter widget for applying nlp to pdf documents
Project description
PDF Digitizer (It has a back button!!)
A Jupyter-based tool to help parse out structured text from a PDF document and explore the contents.
Installation
Pip
Install Tesseract
pip install ipypdf
python -m spacy download en_core_web_lg
Conda
conda install -c conda-forge ipypdf
conda install -c conda-forge spacy-model-en_core_web_lg
Development
see DEVELOPMENT.md
Usage
from ipypdf import App
app = App("path/to/your/pdfs", bulk_render=False)
app
Features
Auto-Parser
layoutparser
is used to determine the location of textblocks, images, and section headers. There is not currently a way to automatically determine the hierarchical position of these items.
Note: this is 4x speed
Also: This video is out-dated now. The AutoParse button will now attempt to sort all of the nodes. As well as attempting to deduce the 1st level of hierarchical structure.
Table Parsing
Cytoscape
Folders
, PDF Documents
, and Sections
have a tab labeled Cytoscape
. This runs a tfidf similarity calculation over all nodes beneath the selected item. I.e. if you select the root node, then all defined nodes will be included in the calculation. However, only those with a link to another node will be drawn (this is for speed, may change this in the future).
The color of each node denotes the pdf document it originated from.
Selecting a node in the graph will highlight the node in the DocTree
. Clicking the node in the DocTree
will render the first page of the node.
Digitizing Utilities
I recommend turning off
Show Boxes
as this changes pages every time you add a node (working on a better solution)
Each node has a specific set of tools available to use. Here are the tools provided when a Section
node is selected.
Starting from the left:
Add Section Node
adds a sub-node of typeSection
and selects itAdd Text Node
adds a sub-node of typeText
and selects itAdd Image Node
...Delete Node
Delete the selected node and all of its children
Content Selector
Content is extracted from the rendered image. Text is extracted using Optical Character Recognition (OCR). Images don't do any image analysis, they just denote coordinates and page number so that they can be retreived later if need be.
When a Section
node is selected, the selection tool will attempt to parse text from the portion of the page selected by the user. This text will overwrite the label assigned to the node.
When a Text
node is selected, the selection tool will attempt to parse text from the selected area and append it to the node's content. This is because text blocks are not always perfectly rectangular, and often span multiple pages.
When an Image
node is selected, the coordinates of the box are appended to the node's content.
Save Button
This will generate json
files for each document in the directory with instructions for regenerating any nodes you have created when you open the tool again. Alternatively, you can just load the json into another script to extract the document structure if all you want is the text and the hierarchy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ipypdf-0.0.5.tar.gz
.
File metadata
- Download URL: ipypdf-0.0.5.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 967f1914377f7050b09562564c4ca556dc0191c031121b776222b428625bdab6 |
|
MD5 | 56b4c7b401bbb56a8388e2fdc413d78c |
|
BLAKE2b-256 | 723dd2ca1a0901ebfa692a6b346cbd2a366e9d0356431e04c9f9625d09b947f1 |
File details
Details for the file ipypdf-0.0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: ipypdf-0.0.5-py2.py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db3437412edc59872c724876c885fbfaa182c746c5ae926edd5b6b5f4f59550 |
|
MD5 | e2659175f4aa7fa0f09c746d33f329f4 |
|
BLAKE2b-256 | db54edfd25b2b1a1688a107b50326ff6de3014ea56164acf04478296c3717abd |