Skip to main content

rakam-systems-documents

Generic document preparation: turn any source document into clean, structured, provenance-tagged content the rest of the stack can reason over.

from rakam_systems_documents import prepare, MistralOCRProvider

pc = prepare(raw_bytes, mime="application/pdf", filename="invoice.pdf",
             ocr=MistralOCRProvider())      # ocr optional; native PDFs skip it
pc.markdown      # what a model reads
pc.rows          # structured rows (tabular sources), header-keyed + provenance
pc.provenance    # page/sheet/row refs
pc.provider      # pdf_text | mistral_ocr | docling_ocr | tabular | text | none

What it is (and isn't)

One job: bytes -> PreparedContent. Format dispatch, parse/decode, hybrid-OCR routing, provenance normalization, truncation. A pure function — the only I/O is the injected OCR provider.

Not its job: storage, chunking, embedding, indexing, async/status, or any business meaning (extraction, matching, classification). Those belong to the caller — the library gives every caller one document→content primitive so none reimplements parsing/OCR.

Formats

Source Handling
Native PDF pymupdf4llm → markdown (text layer, exact, no egress)
Scanned PDF / image hybrid gate → OCR provider (see below)
Excel / CSV openpyxl / csv → markdown table + structured rows + (sheet,row) provenance
Word (.docx) stdlib zip + WordprocessingML → paragraphs (headings kept) and markdown tables + header-keyed rows, in document order
Email (.eml) rfc822 headers + body (html bodies stripped to text) + every attachment prepared in turn under ## Pièce jointe : <name>
Text multi-encoding decode (binary rejected)
Legacy .xls / .doc / .msg not parsed — provider="none" with a "save as .xlsx/.docx/.eml" hint

OCR is pluggable

Native-text PDFs never hit OCR. Scanned pages / images route to an OCRProvider:

  • MistralOCRProvider (default) — the Mistral hosted OCR API (/v1/ocr). Needs MISTRAL_API_KEY.
  • DoclingOCRProvider — on-prem, no egress. Requires the optional extra: pip install rakam-systems-documents[docling].

A missing/unavailable engine degrades gracefully (native text still works; a scan yields provider="none" + a help hint, never an exception).

Install

pip install rakam-systems-documents            # Mistral OCR path
pip install rakam-systems-documents[docling]    # + on-prem OCR

Release files for rakam-systems-documents 0.1.2

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

Source distribution (sdist)

Source distribution for rakam-systems-documents 0.1.2
File Size Uploaded
rakam_systems_documents-0.1.2.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rakam-systems-documents 0.1.2
File Interpreter ABI Platform
rakam_systems_documents-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.4 kB

Release files / rakam_systems_documents-0.1.2.tar.gz

Download URL rakam_systems_documents-0.1.2.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b1896da5be427e5737e2f63dbf2e605170952f6c9f55ea4bb0d8741912cf1950
BLAKE2b-256 checksum
How to use checksums
fa082226e2c1a51db6a641facac436f74d83d9738b748f5ab1d199ea7788dafd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / rakam_systems_documents-0.1.2-py3-none-any.whl

Download URL rakam_systems_documents-0.1.2-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
421ca7126552391aa2b99ad7953ab3d6e2475f5e0eb8a12360c1e39ef98ed162
BLAKE2b-256 checksum
How to use checksums
3cf288bda45a1a1c8b44f0025848288bb270307b7f120e5b834dffbffb55747d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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