getpaper - papers download made easy!
Project description
getpaper
Paper downloader
getting started
Install the library with:
pip install getpaper
Usage
Downloading papers
After the installation you can either import the library into your python code or you can use the console scripts.
If you install from pip calling download will mean calling getpaper/download.py , for parse - getpaper/parse.py , for index - getpaper/index.py
download download download_pubmed --pubmed 22266545 --folder papers --name pmid
Downloads the paper with pubmed id into the folder 'papers' and uses the pubmed id as name
download download download_doi --doi 10.1519/JSC.0b013e318225bbae --folder papers
Downloads the paper with DOI into the folder papers, as --name is not specified doi is used as name
It is also possible to download many papers in parallel with download_papers(dois: List[str], destination: Path, threads: int) function, for example:
from pathlib import Path
from typing import List
from getpaper.download import download_papers
dois: List[str] = ["10.3390/ijms22031073", "10.1038/s41597-020-00710-z", "wrong"]
destination: Path = Path("./data/output/test/papers").absolute().resolve()
threads: int = 5
results = download_papers(dois, destination, threads)
successful = results[0]
failed = results[1]
Here results will be OrderedDict[str, Path] with successfully downloaded doi->paper_path and List[str] with failed dois, in current example:
(OrderedDict([('10.3390/ijms22031073',
PosixPath('/home/antonkulaga/sources/getpaper/notebooks/data/output/test/papers/10.3390/ijms22031073.pdf')),
('10.1038/s41597-020-00710-z',
PosixPath('/home/antonkulaga/sources/getpaper/notebooks/data/output/test/papers/10.1038/s41597-020-00710-z.pdf'))]),
['wrong'])
Same function can be called from the command line:
download download_papers --dois "10.3390/ijms22031073" --dois "10.1038/s41597-020-00710-z" --dois "wrong" --folder ""/home/antonkulaga/sources/getpaper/notebooks/data/output/test/papers" --threads 5
Parsing the papers
You can parse the downloaded papers with the unstructure library. For example if the papers are in the folder test, you can run:
getpaper/parse.py parse_folder --folder /home/antonkulaga/sources/getpaper/test
You can also parse papers on a per file basis, for example:
getpaper/parse.py parse_paper --paper /home/antonkulaga/sources/getpaper/test/22266545.pdf
Indexing papers
We also provide features to index the papers with openai or lambda embeddings and save them in chromadb vector store. For openai embeddings to work you have to create .env file and specify your openai key there, see .env.template as example For example if you have your papers inside data/output/test/papers folder and you want to make a ChromaDB index at data/output/test/index you can do it by:
python getpaper/index.py index_papers --papers data/output/test/papers --folder data/output/test/index --collection mypapers --chunk_size 6000
Examples
You can run examples.py to see usage examples
Additional requirements
Detectron2 is required for using models from the layoutparser model zoo but is not automatically installed with this package. For MacOS and Linux, build from source with:
pip install 'git+https://github.com/facebookresearch/detectron2.git@e2ce8dc#egg=detectron2'
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 getpaper-0.1.3.tar.gz
.
File metadata
- Download URL: getpaper-0.1.3.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38f78f60267ae8c7ddf9d6412321dacb29546b05b690fa25746e5b68180508da |
|
MD5 | c9ab0938401205148e1eee280e3c31b6 |
|
BLAKE2b-256 | 8aeb760b86a1435eb7a1db1716877cd3b3be9ebf5f666cec1b425866808f6968 |
File details
Details for the file getpaper-0.1.3-py2.py3-none-any.whl
.
File metadata
- Download URL: getpaper-0.1.3-py2.py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0afcf0b97e23493c0b4d20256747a3acf1318a01abf5106fe49f65288cb734c8 |
|
MD5 | 28f747afc728b7c5b807e4ec6df4cf50 |
|
BLAKE2b-256 | 6025c8ed62698ae73db7d885a30463c94c182231a11a8cf6733e020497131712 |