arabic-extract
Clean Arabic text extraction from PDFs and scanned images — one call, clean output.
Combines PDF text extraction, image OCR, and arabic-repair into a single pipeline. Handles the visual-order problem that breaks standard Arabic NLP pipelines.
The problem it solves
Arabic PDFs and scanned documents store text in visual order with presentation-form characters. Standard tools (NFKC, CAMeL Tools) remove the presentation forms but cannot restore the reversed word order — retrieval recall stays broken at ~27%. arabic-extract applies arabic-repair automatically, restoring both letter forms and word order before the text reaches your NLP pipeline.
Install
pip install arabic-extract[pdf] # PDF text-layer extraction
pip install arabic-extract[tesseract] # + image OCR via Tesseract (needs binary)
pip install arabic-extract[easyocr] # + image OCR via EasyOCR (pure Python, ~200 MB)
pip install arabic-extract[pymupdf] # + scanned PDF rendering via PyMuPDF
pip install arabic-extract[all] # everything
Tesseract binary (for the tesseract extra):
- Windows: download from https://github.com/UB-Mannheim/tesseract/wiki — install the Arabic language pack
- Linux:
sudo apt install tesseract-ocr tesseract-ocr-ara - macOS:
brew install tesseract && brew install tesseract-lang
Quick start
import arabic_extract as aocr
# PDF — auto-detects text layer vs scanned, repairs each page
result = aocr.extract("document.pdf")
print(result.text) # clean logical Arabic, all pages joined
print(result.pages) # per-page breakdown
print(result.contamination) # how many words needed repair
# Scanned image
result = aocr.extract("scan.jpg")
print(result.text)
# Explicit PDF extraction
result = aocr.extract_pdf("document.pdf", engine="tesseract")
# Explicit image extraction
result = aocr.extract_image("scan.png", engine="easyocr")
# Chain into CAMeL Tools (normalize=True is the default)
result = aocr.extract("document.pdf", normalize=True)
How it works
Input PDF or image
│
├─ PDF with text layer → pdfplumber extracts text (visual order)
│ ↓
├─ Scanned PDF → render page as image → OCR engine
│ ↓
└─ Image file → OCR engine (Tesseract or EasyOCR)
↓
arabic-repair (de-shape + restore order)
↓
NFKC / CAMeL Tools normalization
↓
Clean logical Arabic text
A single PDF can have mixed pages — some with a text layer, some scanned. Each page is handled correctly.
Per-page results
result = aocr.extract("document.pdf")
for page in result.pages:
print(f"Page {page.page_number} [{page.method}]: {page.text[:80]}")
# method: "text_layer" | "ocr" | "text_layer_empty"
Ecosystem
| Package | Role |
|---|---|
| arabic-rt | Core shaping / fix / unfix engine |
| arabic-repair | Detect and repair visual-order contamination |
| arabic-extract | Full PDF + image extraction pipeline |
| arabic-benchmark | Benchmark proving the reordering gap |
License
MPL-2.0
Metadata
Release files for arabic-extract 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| arabic_extract-0.1.0.tar.gz | 10.0 kB | With provenance | Details for arabic_extract-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arabic_extract-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for arabic_extract-0.1.0-py3-none-any.whl |
Total release size: 20.0 kB
Release files / arabic_extract-0.1.0.tar.gz
| Download URL | arabic_extract-0.1.0.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dc5facf7f9d2f4515c783f7e42d332cb3b27d9da0db7425fb51d1e1e56b78fe
|
|
BLAKE2b-256 checksum How to use checksums |
95fc5e9d91dcdfc515775e8a2b140baf1f9de777cf07f6fca94ff6cd5f77c4bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 8, 2026.
Transparency logRelease files / arabic_extract-0.1.0-py3-none-any.whl
| Download URL | arabic_extract-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc949559c712be5c1cc5ed39d895bb6a96937698323a99d85714adae7ee95043
|
|
BLAKE2b-256 checksum How to use checksums |
107dc65d37a330d409ac09d49681534987672546d96b03cdecd13ae7f6a4bb68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jun 8, 2026.
Transparency logSecurity for arabic-extract 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
Both files in this release have been uploaded with provenance metadata.
Attestation for arabic_extract-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 Jun 8, 2026.
Transparency logA 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.