Universe

spadypdfreader

Easy PDF to text to spaCy text extraction in Python.

spacypdfreader is a Python library that allows you to convert PDF files directly into spaCy Doc objects. The library provides several built in parsers or bring your own parser. Doc objects are annotated with several custom attributes including: token._.page_number, doc._.page_range, doc._.first_page, doc._.last_page, doc._.pdf_file_name, and doc._.page(int).

Example

import spacy from spacypdfreader import pdf_reader nlp = spacy.load('en_core_web_sm') doc = pdf_reader('tests/data/test_pdf_01.pdf', nlp) # Get the page number of any token. print(doc[0]._.page_number) # 1 print(doc[-1]._.page_number) # 4 # Get page meta data about the PDF document. print(doc._.pdf_file_name) # 'tests/data/test_pdf_01.pdf' print(doc._.page_range) # (1, 4) print(doc._.first_page) # 1 print(doc._.last_page) # 4 # Get all of the text from a specific PDF page. print(doc._.page(4)) # 'able to display the destination page (unless...'
View more
Author info

Sam Edwardes

GitHubSamEdwardes/spacypdfreader

Categories pipeline

Submit your project

If you have a project that you want the spaCy community to make use of, you can suggest it by submitting a pull request to the spaCy website repository. The Universe database is open-source and collected in a simple JSON file. For more details on the formats and available fields, see the documentation. Looking for inspiration your own spaCy plugin or extension? Check out the project idea label on the issue tracker.

Read the docsJSON source