A PDF to text extraction pipeline component for spaCy.
Project description
spaCyPDFreader
Extract text from pdfs using spaCy and capture the page number as a spacy extension.
Installation
pip install spacypdfreader
Usage
import spacy
from spacypdfreader import pdf_reader
nlp = spacy.load("en_core_web_sm")
doc = pdf_reader("tests/data/test_pdf_01.pdf", nlp)
Extracting text from 4 pdf pages...
100%|██████████| 4/4 [00:00<00:00, 5.97it/s]
doc[0:10]
Test PDF 01
This is a simple test pdf
for token in doc[0:10]:
print(f"Token: `{token}`, page number {token._.page_number}")
Token: `Test`, page number 1
Token: `PDF`, page number 1
Token: `01`, page number 1
Token: `
`, page number 1
Token: `This`, page number 1
Token: `is`, page number 1
Token: `a`, page number 1
Token: `simple`, page number 1
Token: `test`, page number 1
Token: `pdf`, page number 1
doc[-10:]
U3D or PRC and various other data formats.[15][16][17]
for token in doc[-10:]:
print(f"Token: `{token}`, page number {token._.page_number}")
Token: `U3D`, page number 4
Token: `or`, page number 4
Token: `PRC`, page number 4
Token: `and`, page number 4
Token: `various`, page number 4
Token: `other`, page number 4
Token: `data`, page number 4
Token: `formats.[15][16][17`, page number 4
Token: `]`, page number 4
Token: `
`, page number 4
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spacypdfreader-0.1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for spacypdfreader-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 692b7409acd1060cd6f468622b833675f0dd28e25d9f1be257448c4354efe6c5 |
|
MD5 | c6a8aa6e81dfaeae3b0ec4253c5fb716 |
|
BLAKE2b-256 | e25cec2263dfc6a859c1033279f062084eaf687fe538dd239d54ed69fe1ae399 |