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.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 uzru-parser 0.2.0
File Size Uploaded Provenance
uzru_parser-0.2.0.tar.gz 1.6 MB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for uzru-parser 0.2.0
File
uzru_parser-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
uzru_parser-0.2.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
uzru_parser-0.2.0-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.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
uzru_parser-0.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
uzru_parser-0.2.0-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.0.tar.gz

Download URL uzru_parser-0.2.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
41d382528dc434c23fab081000424789cfe0d69a4e0d1114ea7b7e6d33e22039
BLAKE2b-256 checksum
How to use checksums
e61a279483e2ec6238ba17c765dc065fe09fcfd2e518cdde93ff72a69dda5d3a
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-cp310-abi3-win_amd64.whl
Size 980.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
0cb18abcdc8e443648596f041581bcf7837875e47478f2818ad22f201492814f
BLAKE2b-256 checksum
How to use checksums
cf282f857bb858b2983322ef60ba62ec0b75d0aba819b6a109ec5fe541b11d6e
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-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
e17358962600253fa2c3f402a5238fecd271ff57c4819d6f678775a1ca3d86eb
BLAKE2b-256 checksum
How to use checksums
00f3e65742615a6425a2e0e3fa020e304c5ae88979de9ee499aa527373450faf
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-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
c50a661df339ed34b615cbdcebf3a740b0f85c467fbf4cf8063f6c4a8f93c83a
BLAKE2b-256 checksum
How to use checksums
00f1de55dc8c488d3c8067dafba28ddd160e0701d0959a9c53faf7dc2a91b02f
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-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
9255416adfc7eda8dbe47848b265fe19a3f78a5be1680dd6df8c620dcce965ba
BLAKE2b-256 checksum
How to use checksums
988dfa9bfb79d6f722963c0180b86b987e8d10f4c938598b3c8bf1cf8dabdc5c
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-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
73df7d3bdbb18f5d22d83d1c38311a98545790b7e96137bfd5ab2067ebe66fae
BLAKE2b-256 checksum
How to use checksums
0d686d9c25da2f68432c76ee172844c7edf61272ec37bd04b91d7f0f0ddb942a
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 4, 2026.

Transparency log

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

Download URL uzru_parser-0.2.0-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
8d45d7d02fdb632bd2e1d25dcae3e65b12d811668a9ec84a467172cbcb142102
BLAKE2b-256 checksum
How to use checksums
77a133b9dbddb44175f51e1c61c92f63ba90afa7d87a128909c4dc17b1d437a7
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 4, 2026.

Transparency log

Security for uzru-parser 0.2.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

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

Select from 7 files

Attestation for uzru_parser-0.2.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 Oct 4, 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