Metadata-Version: 2.4
Name: paperminertoolkit
Version: 1.1.0
Summary: A package for extracting structured information from scientific papers with configurable language and vision models.
Author-email: Oskar Soulas <oskar.soulas@gmail.com>, Louie <louies@hotmail.co.uk>
License-Expression: MIT
Project-URL: Homepage, https://github.com/SMTG-Bham/PaperMinerToolkit
Project-URL: Repository, https://github.com/SMTG-Bham/PaperMinerToolkit
Project-URL: Issues, https://github.com/SMTG-Bham/PaperMinerToolkit/issues
Keywords: research,scientific-papers,materials,text-mining,llm
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
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: Topic :: Scientific/Engineering :: Chemistry
Classifier: Topic :: Text Processing
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click
Requires-Dist: headroom-ai[image,ml]<0.36,>=0.35
Requires-Dist: openai
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pillow
Requires-Dist: pymupdf
Requires-Dist: pypdf
Requires-Dist: requests
Requires-Dist: regex
Requires-Dist: scipy
Requires-Dist: joblib
Requires-Dist: matplotlib
Requires-Dist: scikit-learn
Requires-Dist: tiktoken>=0.13.0
Requires-Dist: tqdm
Requires-Dist: transformers
Provides-Extra: bert
Requires-Dist: torch; extra == "bert"
Requires-Dist: transformers>=4.30; extra == "bert"
Requires-Dist: sentencepiece; extra == "bert"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: ruff; extra == "test"
Provides-Extra: docs
Requires-Dist: myst-nb<2,>=1.2; extra == "docs"
Requires-Dist: pydata-sphinx-theme<0.21,>=0.16; extra == "docs"
Requires-Dist: sphinx<10,>=8; extra == "docs"
Requires-Dist: sphinx-click<7,>=6; extra == "docs"
Requires-Dist: sphinxcontrib-mermaid<2,>=1; extra == "docs"
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/SMTG-Bham/PaperMinerToolkit/main/assets/Paper_Miner_Toolkit_banner_dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/SMTG-Bham/PaperMinerToolkit/main/assets/Paper_Miner_Toolkit_banner_light.svg">
    <img src="https://raw.githubusercontent.com/SMTG-Bham/PaperMinerToolkit/main/assets/Paper_Miner_Toolkit_banner_light.svg" alt="PaperMinerToolkit banner" width="640">
  </picture>
</p>

<p align="center">
  <a href="https://github.com/SMTG-Bham/PaperMinerToolkit/actions/workflows/tests.yml"><img src="https://github.com/SMTG-Bham/PaperMinerToolkit/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests"></a>
  <a href="https://codecov.io/gh/SMTG-Bham/PaperMinerToolkit"><img src="https://codecov.io/gh/SMTG-Bham/PaperMinerToolkit/branch/main/graph/badge.svg" alt="Coverage"></a>
  <a href="https://pypi.org/project/paperminertoolkit/"><img src="https://img.shields.io/pypi/v/paperminertoolkit?cacheSeconds=300&amp;logo=pypi&amp;logoColor=white" alt="PyPI version"></a>
  <a href="https://www.python.org/"><img src="https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&amp;logoColor=white" alt="Python 3.11 or newer"></a>
  <a href="https://paperminertoolkit.readthedocs.io/"><img src="https://img.shields.io/badge/Docs-Read%20the%20Docs-8CA1AF?logo=readthedocs&amp;logoColor=white" alt="Documentation"></a>
</p>

# PaperMinerToolkit

PaperMinerToolkit builds scientific-paper corpora and extracts structured, recipe-defined data with configurable text and vision models. It searches Elsevier/Scopus, CORE, OpenAlex, PubMed, arXiv, medRxiv, bioRxiv, and chemRxiv; supplements paper metadata from Crossref, OpenAlex, PubMed, arXiv, medRxiv, bioRxiv, and chemRxiv, and imports an author's works from Crossref; downloads abstracts, full text, PDFs, and supporting information; supports persistent regex and LDA topic filters; and stores source content and pipeline state in SQLite.

The complete user guide, CLI reference, Python API, HPC instructions, and rendered notebooks live in the [documentation](https://paperminertoolkit.readthedocs.io/).

## Installation

PaperMinerToolkit requires Python 3.11 or newer:

```bash
pip install paperminertoolkit
```

For local entity extraction with fine-tuned BERT checkpoints, install
`pip install 'paperminertoolkit[bert]'`.

## Quickstart

Probe a public source, then gather a small corpus of abstracts. These steps need no model or API key:

```bash
pmt probe --source arxiv

pmt gather "lithium solid electrolyte" papers.db \
  --source arxiv --count 5 --format abstract --download-source arxiv
pmt corpus stats papers.db
```

`pmt gather` combines search and download, merging duplicate records and downloading only papers matched by that search. Repeat `--source` to search several providers and `--download-source` to select content providers separately. Configure only the [provider credentials](https://paperminertoolkit.readthedocs.io/en/latest/workflow/configuration.html) you need. Use `--json` on `probe` or `gather` for scriptable summaries.

To extract structured records from those abstracts, configure a text model:

```bash
pmt config model text --provider openai --model YOUR_TEXT_MODEL

pmt scrape papers.db sse \
  --mode abstract \
  --output temp_scraped_materials.csv

pmt store papers.db \
  temp_scraped_materials.csv \
  materials.csv \
  sse \
  --assume-yes
```

To recover the curves of the figures that records name, such as a recipe's `Mass loss figure`, use `pmt digitize` with the optional [figrecover](https://github.com/SMTG-Bham/figrecover) package; see [recovering curves from figures](https://paperminertoolkit.readthedocs.io/en/latest/workflow/digitizing.html).

Use `pmt status papers.db` to inspect pipeline progress. `pmt search` and `pmt download` remain available for separate discovery and content retrieval stages.

Text and PDF acquisition also attempts supporting information (SI), and text/image scraping includes stored SI by default. Use `--no-supplements` on `gather`, `download`, or `scrape` to opt out. Abstract-only runs skip SI. To acquire SI for existing entries without redownloading the article or fetching abstracts:

```bash
pmt download papers.db --format supplement
```

Discovery uses stored article links, PMC, public Figshare records tied to the paper DOI, and publisher supplement links. Each file retains its source and separate extraction status; see the [supporting-information workflow](https://paperminertoolkit.readthedocs.io/en/latest/workflow/corpus.html#supporting-information) for coverage and limits.

## CLI automation and AI agents

Discover the installed interface and inspect corpus records without parsing tables:

```bash
pmt --version
pmt schema corpus export
pmt gather "lithium solid electrolyte" papers.db \
  --source arxiv --count 5 --format abstract --download-source arxiv --json
pmt corpus list papers.db --limit 5 --json
pmt status papers.db --json
```

`python -m paperminertoolkit` exposes the same commands. JSON is available on
selected commands through their local `--json` option; progress and errors use
stderr. Preserve JSON even when a search exits with code 1: successful papers
from a partial search remain in the corpus. Use `corpus show` to inspect a paper
and `corpus export` to retrieve a stored abstract, text, or PDF.

The [agent CLI guide](https://paperminertoolkit.readthedocs.io/en/latest/workflow/agents.html)
documents discovery, credentials, JSON shapes, exit codes, and resumable
extraction. The [standard-library subprocess example](examples/agent_cli.py)
closes stdin and handles partial results; run it with `--help` before supplying
a query and explicit corpus path.

## BERT entity extraction

Annotate stored abstracts with a fine-tuned token-classification checkpoint:

```bash
pmt entities corpus papers.db entities.jsonl \
  --model ./models/matscibert-ner --field abstract
```

Replace the example path with your trained checkpoint directory or Hugging Face
model ID. Use `pmt entities text paper.txt entities.jsonl --model CHECKPOINT` for
a UTF-8 file. Results include entity labels, confidence scores, exact text,
character offsets, and source metadata; long documents use overlapping windows.

The published [MatSciBERT](https://huggingface.co/m3rg-iitd/matscibert) base model
requires entity fine-tuning. The published
[polyBERT](https://huggingface.co/HAYDERphd/polyBERT) produces polymer PSMILES
fingerprints and is not a prose entity tagger. Supply a compatible fine-tuned
token classifier; training is not part of this workflow. See the
[entity extraction guide](https://paperminertoolkit.readthedocs.io/en/latest/workflow/entities.html).

## Documentation

Install and build the Sphinx site locally:

```bash
python -m pip install -e '.[docs]'
make -C docs html
```

Open `docs/_build/html/index.html`. Notebook templates for OpenAI, Anthropic, local Qwen/vLLM, LDA model selection, temporal trends, and hybrid filtering are under `docs/examples/`.

## Testing

```bash
python -m pip install -e '.[test]'
ruff check paperminertoolkit tests
pytest
```

PaperMinerToolkit is currently alpha software. Keep the corpus database, recipe, model configuration, intermediate extraction CSV, and final results together so a workflow can be reviewed and reproduced.
