Skip to main content

uzru-parser

CPU-first document parser and chunker for Russian and Uzbek (Latin and Cyrillic) documents, built for retrieval-augmented generation (RAG). A Python API on top of a small Rust core: no GPU, no machine-learning models to download, no network calls.

Alpha (0.2.0). The API may change before 1.0.

Installation

pip install uzru-parser            # DOCX support
pip install "uzru-parser[pdf]"     # DOCX and PDF support
pip install "uzru-parser[layout]"  # PDF support plus the optional layout model (ONNX Runtime)

PDF support uses PyMuPDF, installed by the pdf extra. PyMuPDF is licensed under AGPL-3.0 (or a commercial licence from Artifex): check that this fits your use before installing the extra. Without it, parsing a PDF raises an ImportError that explains how to install it. On Alpine Linux, PyMuPDF also needs the C++ runtime: apk add libstdc++.

Wheels are published for Linux (x86_64, aarch64, musl), macOS (Intel and Apple Silicon) and Windows (x64), for CPython 3.10 and newer.

Quick start

Input: sample.docx, a short Uzbek document with a title and two numbered sections:

Ijara shartnomasi                                   (Heading 1)

1. Umumiy qoidalar                                  (Heading 2)
Ushbu shartnoma ijaraga beruvchi va ijarachi o‘rtasida turar joyni
vaqtincha foydalanishga berish shartlarini belgilaydi.

2. Tomonlarning majburiyatlari                      (Heading 2)
Ijarachi ijara haqini har oyning 10-sanasigacha to‘laydi va turar joyni
ozoda saqlaydi.

Code:

import json
from uzru_parser import Chunker, parse

document = parse("sample.docx")  # or "sample.pdf" with the pdf extra
chunks = Chunker(max_tokens=600, overlap=80).chunk(document)

for chunk in chunks:
    print(json.dumps(chunk.to_dict(), ensure_ascii=False, indent=2))

Output: one JSON object per chunk, each section with the headings above it:

{
  "chunk_id": "61725848e421179b-0000",
  "document_id": "61725848e421179b",
  "text": "Ijara shartnomasi\n\n1. Umumiy qoidalar\n\nUshbu shartnoma ijaraga beruvchi va ijarachi oʻrtasida turar joyni vaqtincha foydalanishga berish shartlarini belgilaydi.",
  "language": "uz",
  "script": "latin",
  "page_start": 1,
  "page_end": 1,
  "heading_path": [
    "Ijara shartnomasi",
    "1. Umumiy qoidalar"
  ],
  "chunk_index": 0,
  "token_count": 44,
  "metadata": {
    "content_type": "prose",
    "content_types": [
      "prose"
    ],
    "language_source": "chunk"
  }
}
{
  "chunk_id": "61725848e421179b-0001",
  "document_id": "61725848e421179b",
  "text": "2. Tomonlarning majburiyatlari\n\nIjarachi ijara haqini har oyning 10-sanasigacha toʻlaydi va turar joyni ozoda saqlaydi.",
  "language": "uz",
  "script": "latin",
  "page_start": 1,
  "page_end": 1,
  "heading_path": [
    "Ijara shartnomasi",
    "2. Tomonlarning majburiyatlari"
  ],
  "chunk_index": 1,
  "token_count": 33,
  "metadata": {
    "content_type": "prose",
    "content_types": [
      "prose"
    ],
    "language_source": "chunk"
  }
}

ensure_ascii=False keeps Cyrillic and Uzbek letters readable instead of \u escapes. document.to_dict() gives the whole parsed document (pages, blocks, language) the same way.

Output

  • Document: metadata (source, format, title, author, page count), pages (with a needs_ocr flag), blocks, and the document language.
  • Blocks: heading (with level), paragraph, list (items in extra["items"]), table, footnote; each with its text, the raw extracted text, page, bounding box (PDF) and its own language. extra["role"] marks material set apart from the running text: title_page, toc, back_matter, figure, formula, caption, image. A document whose first page opens with its title (an act's issuer and name) gets it as metadata.title, not as a heading.
  • Chunks: text of at most max_tokens (estimated, or your own token_counter), the heading_path of headings above it, page range, language and script, and metadata. Headings start new chunks; title page, contents and back matter are left out of chunk text. Tables are cut only between rows; a chunk that goes on with a table starts with its header rows again, and overlap never repeats table rows.
  • Chunk metadata: content_type (prose, list, table, formula, figure, image or mixed) and content_types; tables with the header and rows of each table part in the chunk and whether it is continued from the previous chunk; is_appendix for chunks under an appendix label ("1-ILOVA", "Приложение № 2"); source_title; language_source (chunk, or document when the chunk's text alone tells no language, as a table of chemical names); footnotes.
  • Quality warnings: metadata.extra["quality"]["warnings"] lists what could not be read well: no_text_layer (scanned pages), low_confidence_pages, pictures_not_read (formulas or charts set as pictures: their place in the text is kept as [image]), language_uncertain, little_or_no_text.
  • Language: ru, uz (latin or cyrillic script), mixed or unknown, per block and per chunk.
  • PDF details: metadata.extra["pdf_route"] says how the PDF was read (tagged, rules or rules+layout_model, see below), pdf_tags what its structure tags were, styles the body and heading styles found; each page's extra holds its confidence (0 to 1) and the issues behind it; tables list merged cells in extra["spans"].

PDF routes

  • Tagged PDFs (for example Word's "Save as PDF" with document structure tags): the author's headings, paragraphs, lists, tables and notes are read from the tags, after checking that they cover the text and follow the page. Needs PyMuPDF 1.26.6 or newer.
  • Other PDFs are rebuilt from the layout: a style profile of the whole document (body and heading styles), headings that need a heading style and a second signal (numbering, bookmarks or contents, space around them), an XY-cut reading order for columns, ruled and unruled tables, and a confidence score per page.
  • Optional layout model (off by default): with the layout extra, Parser(layout_model=True) lets PP-DocLayout-S (Apache-2.0, 4.7 MB as ONNX, about 20 ms a page on a CPU) correct the pages with low confidence: tables, figures, formulas, headers and footers, titles, reading order. Point UZRU_LAYOUT_MODEL at the ONNX file (or pass its path as layout_model); without the file or ONNX Runtime the parser runs as usual and says why in metadata.extra["layout_model"].

Supported formats

Format Reader Notes
DOCX python-docx Word styles, outline levels, bold subheadings, Word list numbering, tables
PDF PyMuPDF (pdf extra) Text-based PDFs; structure tags when present; headings, lists, ruled and unruled tables, footnotes, contents pages

Limitations

  • No OCR: scanned or image-only pages produce no text and get needs_ocr = True.
  • PDF layout: single-column pages are the main target; two- and three-column pages, also with different column layouts above and below, are reordered; complex layouts may need the optional layout model, which was trained on Chinese and English documents.
  • DOCX page numbers are approximate (taken from page breaks).
  • English text is labelled unknown (also the whole document when most of it is English).
  • Formulas and charts are reduced to formula / figure blocks; pictures inside the text become [image] placeholders (their content needs OCR).
  • PDF parsing from several threads is safe but serialised (PyMuPDF is not thread-safe); use processes for parallelism.

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[pdf,dev]"
pytest && ruff check . && mypy
cargo test

See ARCHITECTURE.md for the design and CHANGELOG.md for changes.

Licence

  • Source code: MIT.
  • Bundled data files (language model and word list in src/data/): CC BY-SA 4.0, because they are adapted from CC BY-SA 4.0 corpora (notice).
  • Optional PDF backend: PyMuPDF, AGPL-3.0 or commercial licence from Artifex.

Third-party sources, their licences and the required notices are listed in THIRD_PARTY.md.

Metadata

Release files for uzru-parser 0.2.1

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

Source distribution (sdist)

Source distribution for uzru-parser 0.2.1
File Size Uploaded Provenance
uzru_parser-0.2.1.tar.gz 1.6 MB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for uzru-parser 0.2.1
File
uzru_parser-0.2.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
uzru_parser-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
uzru_parser-0.2.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
uzru_parser-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 8.1 MB

Release files / uzru_parser-0.2.1.tar.gz

Download URL uzru_parser-0.2.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
4a6cdd1ad55b9f66d91baccd24c43949e2852d949dcdc141f397980db14fa88e
BLAKE2b-256 checksum
How to use checksums
0d6f58e609b89ffd83b0802afc27d9fcb08e28223c2a52ee2fea9d55e9d124dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-win_amd64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-win_amd64.whl
Size 981.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
701c22bc8c22e2cc8331cde207285910890f2cb82aff01ede8adbd9e839f7525
BLAKE2b-256 checksum
How to use checksums
153d2e7a6afe54a2e2df7b62623529918cd939ab04f769250c94152ff04b1665
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-musllinux_1_2_x86_64.whl
Size 1.3 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
32a44796a46135aa3f29c365f622f4c5b012f9a237dbf93163bb73f647384fc8
BLAKE2b-256 checksum
How to use checksums
4425ce509241512b901f48b82bd6c3cf92bfaa9e7be209d2b23dd518053a0ed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
f26f5827c9775e857a3ee8691a2809a135526815a2602e35856deb2a5f4798dd
BLAKE2b-256 checksum
How to use checksums
6d273d3e124af3a67729bc8cc68542624abcb6cc58eb168dee6ab6f9e11a80a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.1 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
b34eae6dd7fe35698929185cb352ddb5994dd7a3e91eff3cdcdcd8be8eee6fcf
BLAKE2b-256 checksum
How to use checksums
5d09b385e0a851defa78343d24d832c9031b5b8b1949064de75321369a380856
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8dba9a8cb77f19a39b0fa13e12a15ddf4266d4d0f78f9ba48151a439b7913ebc
BLAKE2b-256 checksum
How to use checksums
fbb8df7a1f4de4d3add479950bb5a90ab9eec0797663dede40272da87b9a7b75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Release files / uzru_parser-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL uzru_parser-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f926f75d522867d87a2c6312d1d2730b54151fae7adf0c3ac6b515f152e3f3eb
BLAKE2b-256 checksum
How to use checksums
5f536086658810275bcbce6ed2bafd3cb08525d7bddb6094d65234dc075eb4a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 5, 2026.

Transparency log

Security for uzru-parser 0.2.1

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

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for uzru_parser-0.2.1.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 Oct 5, 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