A Python package for automated publisher-agnostic corpus download and structured Markdown file conversion for full-text scientific publications.
Attempt download of full-text PDFs and XML files for all publications listed in a Scopus query CSV file by DOI. Download is attempted first via open-access routes including arXiv, bioRxiv and Unpaywall. On failure, download is attempted using specific publisher APIs including Elsevier, Wiley, Springer, MDPI, Frontiers.
API keys are required for publishers that do not support fully automated text-mining
Converts downloaded PDFs and XML files into a single, structured JSON format. XMLs are parsed directly, and PDFs are converted locally via MinerU (GPU can be used here for performance improvements – See MinerU). Captures other outputs including raw texts and figures.
Converts JSON-structured text into a standardised Markdown format. A single Markdown file is generated for each document. Supports parameters for toggling inclusion of manuscript sections: figures, tables, references, and Latex equations.
The "force_imrad_structure" parameter will force each output Markdown file to contain marked sections for "Introduction" "Methods", "Results" and "Discussion" (can be omitted).
from main import download_corpus, transform_text, standardise_text, build_new_corpus
# Make a new corpus and set it as active (writes CORPUS_NAME to secrets.env)
build_new_corpus(name="my_corpus", scopus_file="path/to/scopus.csv", set_active=True)
# Attempt download for all DOIs:
publications = download_corpus(check_opensource=True, generate_report=True)
# Run OCR and XML parser to generate JSON document structures:
publications = transform_text(publications)
# Build final markdown files:
standardise_text(publications, keep_figures=False, keep_tables=True, keep_latex=True, force_imrad_structure=True)Publication Python objects are returned at each step and are useful for integrating the package within larger
Python workflows. For example, storing each publication as a Python object makes it easy to query metadata and filepaths:
from main import download_corpus
publications = download_corpus(check_opensource=True)
# Query metadata for all DOIs in the active corpus:
for pub in publications:
print(pub.doi,
pub.title,
pub.abstract,
pub.publisher,
pub.document_type,
pub.publication_filepath,
pub.final_md_filepath
)All user-facing settings live in secrets.env (copy from secrets.env.example):
| Setting | Description |
|---|---|
CORPUS_NAME |
Name of the active corpus folder under corpora/ |
USER_EMAIL |
Your email address (required by some publisher APIs) |
WILEY_TDM_TOKEN |
Wiley TDM API token (optional) |
SPRINGER_API_KEY |
Springer API key (optional) |
ELSEVIER_API_KEY |
Elsevier API key (optional) |
LLM_BASE_URL |
OpenAI-compatible endpoint for the fallback section classifier (defaults to local Ollama) |
LLM_MODEL_NAME |
Model used by the fallback classifier (default gemma3:12b) |
All inputs and outputs for a scopus query live under corpora/<corpus_name>/. The active corpus is selected by setting
CORPUS_NAME in secrets.env. Each corpus folder has the following structure:
corpora/
└── <corpus_name>/
├── scopus.csv # Scopus query export (input — you need to place this here)
├── manuscripts/ # Downloaded full-text PDFs/XMLs output of `extract_text()`
├── intermediates/ # MinerU output files and JSON structures - output of `transform_text()`
├── results/ # Final standardised Markdown files - output of `standardised_text()`
├── reports/ # All HTML output reports.
├── logs/ # Run logs
└── sqlite.db # SQLite cache for this corpus
Everything except scopus.csv is created automatically on the first run when defining a new active corpus. You can
create a new corpus by running the function create_corpus(name="my_corpus", scopus_file="path/to/scopus.csv").
- Python 3.12–3.13:
- Optional: A CUDA-capable GPU (big speedup for PDF conversion via MinerU) +
torch(CUDA 12.8) - Optional: Ollama running
gemma3:12b(~8 GB), used as an LLM fallback to classify ambiguous section headings. Without it, the pipeline runs, but accuracy in removing paper boilerplate is decreased.
Core dependencies: pandas, pydantic, requests, playwright, plotly, openai, wiley-tdm, mineru[pipeline], torch
Install with uv:
uv pip install biomarkitOr with pip:
pip install biomarkit