Metadata-Version: 2.4
Name: refextract
Version: 1.1.6
Summary: Small library for extracting references used in scholarly communication.
License: GPL-2.0-or-later
License-File: LICENSE
Author: CERN
Author-email: admin@inspirehep.net
Requires-Python: >=3.11,<4
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Dist: inspire-utils (>=3.0.61,<4.0.0)
Requires-Dist: pypdf (>=5.4.0,<6.0.0)
Requires-Dist: python-magic (>=0.4.27,<0.5.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Requires-Dist: unidecode (>=1.0.22,<2.0)
Project-URL: Homepage, https://github.com/inspirehep/refextract
Description-Content-Type: text/markdown


# refextract

## About

A library for extracting references used in scholarly communication.

## Getting Started

Note: due to the usage of `mmap` resize functionality this library cannot be locally installed on a mac

### Docker Setup:

Before the first usage, or anytime a new library/dependency is changed a new docker image must be created using:
```shell
docker build --target refextract-tests -t refextract .
```

After that, spin up a `refextract` service with:
```shell
docker run -it -v ./tests:/refextract/tests -v ./refextract:/refextract/refextract  refextract
```

### Running tests

Exec into the container via
```shell
docker exec -it refextract /bin/bash
```
Then simply run
```shell
pytest .
```

## Usage

To get structured information from a publication reference:


``` python
>>> from refextract import extract_journal_reference
>>> reference = extract_journal_reference('J.Phys.,A39,13445')
>>> print(reference)
{
'extra_ibids': [],
'is_ibid': False,
'misc_txt': '',
'page': '13445',
'title': 'J. Phys.',
'type': 'JOURNAL',
'volume': 'A39',
'year': '',

}
```

To extract references from a PDF:
``` python
>>> from refextract import extract_references_from_file
>>> references = extract_references_from_file('1503.07589.pdf')
>>> print(references[0])
{
'author': ['F. Englert and R. Brout'],
'doi': ['doi:10.1103/PhysRevLett.13.321'],
'journal_page': ['321'],
'journal_reference': ['Phys. Rev. Lett. 13 (1964) 321'],
'journal_title': ['Phys. Rev. Lett.'],
'journal_volume': ['13'],
'journal_year': ['1964'],
'linemarker': ['1'],
'raw_ref': ['[1] F. Englert and R. Brout, \u201cBroken symmetry and the mass of gauge vector mesons\u201d, Phys. Rev. Lett. 13 (1964) 321, doi:10.1103/PhysRevLett.13.321.'],
'texkey': ['Englert:1964et'],
'year': ['1964'],
}
```

To extract directly from a URL:
``` python
>>> from refextract import extract_references_from_url
>>> references = extract_references_from_url('https://arxiv.org/pdf/1503.07589.pdf')
>>> print(references[0])
{
'author': ['F. Englert and R. Brout'],
'doi': ['doi:10.1103/PhysRevLett.13.321'],
'journal_page': ['321'],
'journal_reference': ['Phys. Rev. Lett. 13 (1964) 321'],
'journal_title': ['Phys. Rev. Lett.'],
'journal_volume': ['13'],
'journal_year': ['1964'],
'linemarker': ['1'],
'raw_ref': ['[1] F. Englert and R. Brout, \u201cBroken symmetry and the mass of gauge vector mesons\u201d, Phys. Rev. Lett. 13 (1964) 321, doi:10.1103/PhysRevLett.13.321.'],
'texkey': ['Englert:1964et'],
'year': ['1964'],

}

```

## Notes
`refextract` depends on

[pdftotext](http://linux.die.net/man/1/pdftotext).

## Acknowledgments

`refextract` is based on code and ideas from the following people, who

contributed to the `docextract` module in Invenio:
- Alessio Deiana
- Federico Poli
- Gerrit Rindermann
- Graham R. Armstrong
- Grzegorz Szpura
- Jan Aage Lavik
- Javier Martin Montull
- Micha Moskovic
- Samuele Kaplun
- Thorsten Schwander
- Tibor Simko

## License
GPLv2

