extract_references()
Find the DOIs that the seed papers cite, in one PDF or in every PDF in a folder.
extract_references(
source: str,
save: str | None = None,
cache: bool = True,
) -> list[dict]
Source: theoryminer/prepare/dois.py
The function reads every page of each seed paper and finds each DOI. It repairs a DOI
that the PDF cut at a line end (“10.1007/s1096 4-015-0354-5”). It leaves out the DOI of
the seed itself and the DOIs of its parts (figures, tables). A reference that prints no
DOI cannot be found. A bad file does not stop the run: the summary names it.
It writes a CSV file only when you give save.
Arguments
source
The seed paper, or the folder of seed papers, to read.
- Values: the path of one PDF file, or the path of a folder. The function looks in the folder only, not in its subfolders.
- Default: none. Give a path.
save
Where to write the rows as a CSV file, with the columns doi, n_seeds, cited_by. A download tool can read its “doi” column.
- Values: None, a path that ends with “.csv”, or a folder (then <folder>/references.csv). A missing folder is made.
- Default
None: write no file.
cache
Whether to use the page cache <pdf>.pages.json beside each PDF.
- Values: True or False.
- Default
True: read the cache when it exists, else read the PDF and write the cache. False reads every PDF again and writes no cache.
Returns
A list of dicts, one per unique reference DOI, with the keys
| key | meaning |
|---|---|
doi | the DOI, in lowercase |
n_seeds | the number of seed papers that cite it |
cited_by | the doc_ids of those seed papers |
The DOIs that most seeds cite come first.
Raises
ValueError: The source does not exist, or the folder has no PDF.
Example
>>> refs = extract_references("sample_files")
>>> refs[0]["doi"], refs[0]["n_seeds"]
('10.1037/0003-066x.55.1.68', 2)