Metadata-Version: 2.4
Name: versed-pdf
Version: 1.3.0
Summary: Semantic PDF-to-Markdown engine for Arabic and bilingual texts with local routing and repair
Author: Versed Team
License: MIT
Keywords: arabic,pdf,markdown,text-extraction,quran,ocr,nlp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing :: Linguistic
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: pdf
Requires-Dist: pymupdf>=1.24.0; extra == "pdf"
Requires-Dist: Pillow>=10.0.0; extra == "pdf"
Requires-Dist: fonttools>=4.0.0; extra == "pdf"
Provides-Extra: ocr
Requires-Dist: pytesseract>=0.3.10; extra == "ocr"
Requires-Dist: Pillow>=10.0.0; extra == "ocr"
Provides-Extra: semantic
Requires-Dist: torch>=2.0.0; extra == "semantic"
Requires-Dist: transformers<6,>=4.40.0; extra == "semantic"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# versed

Local PDF-to-Markdown tooling for Arabic and bilingual texts.

It repairs broken extraction, decodes QCF Quran fonts, classifies pages, and renders semantic Markdown from local PDFs.
It also normalizes parsed OpenITI block JSON into the same public `Document`
and markdown/plain-text outputs.

## Install

```bash
pip install versed-pdf
pip install versed-pdf[pdf]
pip install versed-pdf[pdf,ocr]
pip install versed-pdf[semantic]  # optional multilingual alignment evidence
```

## Quick start

```python
from versed import extract_document

result = extract_document("book.pdf", title="Book")
print(result.markdown)
```

OpenITI normalization:

```python
from versed import build_openiti_markdown

parsed = {
    "metadata": {"title": "رسالة"},
    "content": [
        {"type": "title", "content": "رسالة"},
        {"type": "pageNumber", "content": {"volume": "01", "page": "218"}},
        {"type": "paragraph", "content": "قال المصنف ..."},
    ],
}

result = build_openiti_markdown(parsed)
print(result.markdown)
```

## CLI

```bash
versed repair-text "tafß¬l"
versed detect book.pdf
versed classify book.pdf
versed extract book.pdf -o book.md
versed alignment-doctor
versed align arabic.mARkdown english.pdf -o aligned.zip
versed verify-alignment aligned.zip
```

## Public modules

- `versed.repair`: Sabon mojibake repair helpers
- `versed.qcf`: QCF Quran font decoding
- `versed.classify`: local page classification and backend selection
- `versed.routing`: cost-aware routing heuristics
- `versed.layout`: aligned words to semantic blocks
- `versed.markdown`: semantic blocks to Markdown/plain text
- `versed.openiti`: parsed OpenITI block JSON to `Document` and markdown
- `versed.extract`: end-to-end local extraction
- `versed.alignment`: OpenITI mARkdown to English PDF/TXT hierarchical alignment

The aligner keeps structural, paragraph, and sentence links together, zooms out
to a bounded region when exact boundaries are weak, and writes reviewable,
checksummed ZIP bundles. Models are optional and replaceable; no model is
downloaded by the deterministic core. See [the alignment guide](docs/ALIGNMENT.md).

## License

MIT
