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.1.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": {}
}
{
  "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": {}
}

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.
  • 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 (footnotes of the chunk). Headings start new chunks; title page, contents and back matter are left out of chunk 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.
  • Formulas and charts are reduced to formula / figure blocks.
  • 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.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 uzru-parser 0.1.0
File Size Uploaded Provenance
uzru_parser-0.1.0.tar.gz 1.5 MB With provenance Details

Built distributions (wheels)

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

Total release size: 8.0 MB

Release files / uzru_parser-0.1.0.tar.gz

Download URL uzru_parser-0.1.0.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
453520108f99b4e90a45d27b56516f0eef6984bcb18f971caab4971bfc6352f4
BLAKE2b-256 checksum
How to use checksums
8492ce2533b87315445454dd59cb8ea2208f9e19041518270cc132965baa12f6
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.1.0-cp310-abi3-win_amd64.whl

Download URL uzru_parser-0.1.0-cp310-abi3-win_amd64.whl
Size 963.8 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
85ebbd1ade7fe7f468c2eb4256841097efb3309e17361065cf057835bf5c7440
BLAKE2b-256 checksum
How to use checksums
73210a55c00f7b75be14c22a183b61d6119799b4a9019a6ad0c1c4a49f546f2c
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.1.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL uzru_parser-0.1.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
c611a237d2b8d6aabb468b26cec555ebdef3ed832ecb7c079e3825b17eb6cb28
BLAKE2b-256 checksum
How to use checksums
b9f9161b39a501874ed01d41d0a2f8561ea4c3a2cb4552f78715723715aef209
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.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL uzru_parser-0.1.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
d389adf4874267932c28290951d49687c1f1d92731a86295fe35f8258abcd3b8
BLAKE2b-256 checksum
How to use checksums
b19f1d52749de0fc54d735b0d411b27ece25df40514a4660f83dc41fbf6f7f9a
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.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL uzru_parser-0.1.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
80a5115e05ad3b3408bfd1c45e90f2af86906d506dbb1ee59a90563ccc3d487d
BLAKE2b-256 checksum
How to use checksums
4cb175bf281f6a70a05a5de60223e4e46733013bc98b2820dd5744aa47606f71
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.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL uzru_parser-0.1.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
fbadee89ca2a0ef7e35b11afb720bd13b758147809cec78d4591c2e3e703cb05
BLAKE2b-256 checksum
How to use checksums
d2a37258adb3636ac715a8753659e675e298db88a3d190ad4a491dafa5fac922
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.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL uzru_parser-0.1.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
30757271456f0cbaea9000ffacb835731a17f4b4852da68ff6d3fbf0de7a35a3
BLAKE2b-256 checksum
How to use checksums
0c09de09dab186bbaccf62aa9216bdf73510622e3a74105e0ce33fc94e53caa9
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.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

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

Select from 7 files

Attestation for uzru_parser-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 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