Skip to main content

grobid-tei

grobid-tei is a reusable Python client for an independently managed GROBID service and a parser for its TEI XML output. It supports Python 3.10 and newer. It does not start Docker or manage the GROBID service lifecycle.

Installation

pip install grobid-tei

For a local checkout, install the package and its test tools with uv:

uv pip install .
uv sync --extra test

Pre-commit checks

Install pre-commit and enable the repository hooks:

uv tool install pre-commit
pre-commit install
pre-commit run --all-files

The hooks check common file issues, format with Black, lint with Ruff, ensure Python 3.10-compatible syntax, and run the test suite. The copied TEI XML fixture is excluded from whitespace-fixing hooks so its source representation is preserved.

Convert a PDF to TEI

Start or otherwise provide a GROBID service yourself, then configure its full base URL explicitly:

from pathlib import Path

from grobid_tei import GrobidClient, TEIDocument

client = GrobidClient(service_url="http://localhost:8070", timeout=180)
if not client.is_available():
    raise RuntimeError("GROBID is not available")

tei_xml = client.process_fulltext(Path("paper.pdf"))
Path("paper.tei.xml").write_bytes(tei_xml)

document = TEIDocument.from_bytes(tei_xml)
print(document.metadata())
print(document.abstract())
print(document.references(include_citation_counts=True))

process_fulltext returns XML bytes. To enable GROBID consolidation explicitly, pass consolidate_header=True and/or consolidate_citations=True.

Parse an existing TEI file

No running GROBID service is needed to parse an existing file:

from pathlib import Path

from grobid_tei import TEIDocument

document = TEIDocument.from_file(Path("paper.tei.xml"))
print(document.grobid_version())
print(document.keywords())
print(document.author_details())

for paragraph in document.iter_paragraphs():
    print(paragraph)

Public API

  • GrobidClient(service_url=..., timeout=180.0) provides is_available(), version(), and process_fulltext(...).
  • TEIDocument.from_bytes(...) and TEIDocument.from_file(...) create a parsed document. It provides to_bytes(), grobid_version(), metadata(), abstract(), keywords(), author_details(), references(), citations_by_section(), iter_paragraphs(), and annotate_reference_ids(...).
  • TEIReference is a mapping of generic lowercase bibliographic fields (title, author, year, doi, journal, and similar), with the GROBID identifier in .tei_id and an optional citation count in .in_text_citation_count. The identifiers and count are not included in its bibliographic field mapping.
  • GrobidServiceError describes service request failures; TEIParsingError describes unsafe or invalid TEI XML. Both inherit from GrobidTEIError.

The parser uses defusedxml for safe XML parsing. annotate_reference_ids() applies only a caller-supplied mapping from TEI IDs to caller IDs; it performs no reference matching or workflow decisions.

License

This project is licensed under the MIT License.

Metadata

Release files for grobid-tei 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grobid-tei 0.1.0
File Size Uploaded Provenance Actions
grobid_tei-0.1.0.tar.gz 746.0 kB With provenance Details for grobid_tei-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for grobid-tei 0.1.0
File Interpreter ABI Platform Actions
grobid_tei-0.1.0-py3-none-any.whl Python 3 none any Details for grobid_tei-0.1.0-py3-none-any.whl

Total release size: 755.9 kB

Release files / grobid_tei-0.1.0.tar.gz

Download URL grobid_tei-0.1.0.tar.gz
Size 746.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dd84286d3a47a0c2097d5f8044f0ab6e88bf7f2040eb934246c2f64b2534e3f4
BLAKE2b-256 checksum
How to use checksums
05527ba91e622abe469e1b4c3747f2cfc55691680b74a1a3998b5eda2b3816e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / grobid_tei-0.1.0-py3-none-any.whl

Download URL grobid_tei-0.1.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa583a7c859901f645bbe8e08879bbbad16b3d58b049ffe572feaa071f9b8a9f
BLAKE2b-256 checksum
How to use checksums
0a1d2092bb7a8f7980f2728f7b4b15f04c7d568f9d594604422f4950c4256fd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for grobid-tei 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grobid_tei-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page