Python parser for scientific PDF based on GROBID.
Project description
SciPDF Parser
A Python parser for scientific PDF based on GROBID.
Installation
Use pip
to install from this Github repository
pip install git+https://github.com/titipata/scipdf_parser
Note
- We also need an
en_core_web_sm
model for spacy, where you can runpython -m spacy download en_core_web_sm
to download it - You can change GROBID version in
serve_grobid.sh
to test the parser on a new GROBID version
Usage
Run the GROBID using the given bash script before parsing PDF
bash serve_grobid.sh
This script will download GROBID and run the service at default port 8070 (see more here).
To parse a PDF provided in example_data
folder or direct URL, use the following function:
import scipdf
article_dict = scipdf.parse_pdf_to_dict('example_data/futoma2017improved.pdf') # return dictionary
# option to parse directly from URL to PDF, if as_list is set to True, output 'text' of parsed section will be in a list of paragraphs instead
article_dict = scipdf.parse_pdf_to_dict('https://www.biorxiv.org/content/biorxiv/early/2018/11/20/463760.full.pdf', as_list=False)
# output example
>> {
'title': 'Proceedings of Machine Learning for Healthcare',
'abstract': '...',
'sections': [
{'heading': '...', 'text': '...'},
{'heading': '...', 'text': '...'},
...
],
'references': [
{'title': '...', 'year': '...', 'journal': '...', 'author': '...'},
...
],
'figures': [
{'figure_label': '...', 'figure_type': '...', 'figure_id': '...', 'figure_caption': '...', 'figure_data': '...'},
...
],
'doi': '...'
}
xml = scipdf.parse_pdf('example_data/futoma2017improved.pdf', soup=True) # option to parse full XML from GROBID
To parse figures from PDF using pdffigures2, you can run
scipdf.parse_figures('example_data', output_folder='figures') # folder should contain only PDF files
You can see example output figures in figures
folder.
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
scipdf_parser-0.3.tar.gz
(10.4 kB
view hashes)
Built Distribution
Close
Hashes for scipdf_parser-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8e70950b56f8902f05162ac65603102ac9e75e49c1639cdb04a0dfb6606a631 |
|
MD5 | 2364b37af6e1c4cf2dc721b7bb8daa5e |
|
BLAKE2b-256 | 27216a10b26493a372539e2172955e7f4546ed6256b80d1c9db8936aecdf1791 |