{"id":14997609,"url":"https://github.com/samedwardes/spacypdfreader","last_synced_at":"2025-04-13T06:42:34.202Z","repository":{"id":42427420,"uuid":"350198986","full_name":"SamEdwardes/spacypdfreader","owner":"SamEdwardes","description":"Easy PDF to text to spaCy text extraction in Python.","archived":false,"fork":false,"pushed_at":"2024-10-04T23:48:12.000Z","size":2471,"stargazers_count":39,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T23:09:34.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://samedwardes.github.io/spacypdfreader/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SamEdwardes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-22T03:49:18.000Z","updated_at":"2025-03-24T00:00:54.000Z","dependencies_parsed_at":"2022-08-12T10:00:28.907Z","dependency_job_id":"d3d8347e-f179-4174-98cf-6e1a6425a17f","html_url":"https://github.com/SamEdwardes/spacypdfreader","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.125,"last_synced_commit":"5c445b1107df5f12cfdc33b1767245c053b2c9ee"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacypdfreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacypdfreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacypdfreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SamEdwardes%2Fspacypdfreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SamEdwardes","download_url":"https://codeload.github.com/SamEdwardes/spacypdfreader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675440,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T17:04:57.770Z","updated_at":"2025-04-13T06:42:34.183Z","avatar_url":"https://github.com/SamEdwardes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spacypdfreader\n\nEasy PDF to text to *spaCy* text extraction in Python.\n\n\u003cp\u003e\n    \u003c!-- PyPI version --\u003e\n    \u003ca href=\"https://pypi.org/project/spacypdfreader\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://img.shields.io/pypi/v/spacypdfreader?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n    \u003c/a\u003e\n    \u003c!-- PyPi Downloads --\u003e\n    \u003cimg alt=\"PyPI - Downloads\" src=\"https://img.shields.io/pypi/dm/spacypdfreader?label=PyPi%20downloads\"\u003e\n    \u003c!-- Pytest --\u003e\n    \u003ca href=\"https://github.com/SamEdwardes/spacypdfreader/actions/workflows/pytest.yml\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://github.com/SamEdwardes/spacypdfreader/actions/workflows/pytest.yml/badge.svg\" alt=\"pytest\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003chr\u003e\u003c/hr\u003e\n\n**Documentation:** [https://samedwardes.github.io/spacypdfreader/](https://samedwardes.github.io/spacypdfreader/)\n\n**Source code:** [https://github.com/SamEdwardes/spacypdfreader](https://github.com/SamEdwardes/spacypdfreader)\n\n**PyPi:** [https://pypi.org/project/spacypdfreader/](https://pypi.org/project/spacypdfreader/)\n\n**spaCy universe:** [https://spacy.io/universe/project/spacypdfreader](https://spacy.io/universe/project/spacypdfreader)\n\n\u003chr\u003e\u003c/hr\u003e\n\n*spacypdfreader* is a python library for extracting text from PDF documents into *spaCy* `Doc` objects. When you use *spacypdfreader* the token and doc objects from spacy are annotated with additional information about the pdf.\n\nThe key features are:\n\n- **PDF to spaCy Doc object:** Convert a PDF document directly into a *spaCy* `Doc` object.\n- **Custom spaCy attributes and methods:**\n    - `token._.page_number`\n    - `doc._.page_range`\n    - `doc._.first_page`\n    - `doc._.last_page`\n    - `doc._.pdf_file_name`\n    - `doc._.page(int)`\n- **Multiple parsers:** Select between multiple built in PDF to text parsers or bring your own PDF to text parser.\n\n## Installation\n\nInstall *spacypdfreader* using pip:\n\n```bash\npip install spacypdfreader\n```\n\nTo install with the required pytesseract dependencies:\n\n```bash\npip install 'spacypdfreader[pytesseract]'\n```\n\n## Usage\n\n```python\nimport spacy\n\nfrom spacypdfreader import pdf_reader\n\nnlp = spacy.load(\"en_core_web_sm\")\ndoc = pdf_reader(\"tests/data/test_pdf_01.pdf\", nlp)\n\n# Get the page number of any token.\nprint(doc[0]._.page_number)  # 1\nprint(doc[-1]._.page_number)  # 4\n\n# Get page meta data about the PDF document.\nprint(doc._.pdf_file_name)  # \"tests/data/test_pdf_01.pdf\"\nprint(doc._.page_range)  # (1, 4)\nprint(doc._.first_page)  # 1\nprint(doc._.last_page)  # 4\n\n# Get all of the text from a specific PDF page.\nprint(doc._.page(4))  # \"able to display the destination page (unless...\"\n```\n\n## What is *spaCy*?\n\n*spaCy* is a natural language processing (NLP) tool. It can be used to perform a variety of NLP tasks. For more information check out the excellent documentation at [https://spacy.io](https://spacy.io).\n\n## Implementation Notes\n\nspaCyPDFreader behaves a little bit different than your typical [spaCy custom component](https://spacy.io/usage/processing-pipelines#custom-components). Typically a spaCy component should receive and return a `spacy.tokens.Doc` object.\n\nspaCyPDFreader breaks this convention because the text must first be extracted from the PDF. Instead `pdf_reader` takes a path to a PDF file and a `spacy.Language` object as parameters and returns a `spacy.tokens.Doc` object. This allows users an easy way to extract text from PDF files while still allowing them use and customize all of the features spacy has to offer by allowing you to pass in the `spacy.Language` object.\n\nExample of a \"traditional\" spaCy pipeline component [negspaCy](https://spacy.io/universe/project/negspacy):\n\n```python\nimport spacy\nfrom negspacy.negation import Negex\n\nnlp = spacy.load(\"en_core_web_sm\")\nnlp.add_pipe(\"negex\", config={\"ent_types\": [\"PERSON\", \"ORG\"]})\ndoc = nlp(\"She does not like Steve Jobs but likes Apple products.\")\n```\n\nExample of `spaCyPDFreader` usage:\n\n```python\nimport spacy\n\nfrom spacypdfreader import pdf_reader\n\nnlp = spacy.load(\"en_core_web_sm\")\n\ndoc = pdf_reader(\"tests/data/test_pdf_01.pdf\", nlp)\n```\n\nNote that the `nlp.add_pipe` is not used by spaCyPDFreader.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamedwardes%2Fspacypdfreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamedwardes%2Fspacypdfreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamedwardes%2Fspacypdfreader/lists"}