Skip to main content

arabic-repair

Detect and repair visually-baked Arabic text extracted from PDFs, OCR engines, and legacy sources.

The problem

Arabic text stored in old PDF streams, scanned documents (OCR), and legacy systems is often baked: characters are stored as Unicode Presentation Forms (U+FB50–U+FEFF) in reversed visual order rather than logical reading order. Standard tools like Unicode NFKC normalization and CAMeL Tools remove the presentation forms but do not restore the character order — the text remains scrambled.

arabic-repair fixes both: it de-shapes the presentation forms and restores logical word order, then hands clean text to your downstream NLP pipeline.

Install

pip install arabic-repair

Quick start

import arabic_repair as ar

# Repair a string from a PDF extractor or OCR engine
clean = ar.repair(raw_text)

# Inspect contamination before committing to repair
info = ar.detect(raw_text)
print(info.contamination_type)   # "fully_baked" | "partially_baked" | "clean"
print(info.contaminated_ratio)   # 0.0 – 1.0

# Chain into CAMeL Tools for full normalization
from camel_tools.utils.normalize import normalize_unicode
fully_clean = normalize_unicode(ar.repair(raw_text))

# Stream large documents line by line
with open("big_doc.txt", encoding="utf-8") as f:
    for line in ar.repair_stream(f):
        process(line)

What it fixes / what it doesn't

arabic-repair NFKC CAMeL Tools
Presentation forms → base letters ✓ ✓ ✓
Visual order → logical order ✓ ✗ ✗
Alef variant normalization ✗ ✗ ✓
Yaa / teh-marbuta normalization ✗ ✗ ✓
Diacritics ✗ ✗ ✓

Use arabic-repair first, then CAMeL Tools for linguistic normalization.

License

MPL-2.0

Metadata

Release files for arabic-repair 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 arabic-repair 0.1.0
File Size Uploaded Provenance Actions
arabic_repair-0.1.0.tar.gz 7.5 kB With provenance Details for arabic_repair-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for arabic-repair 0.1.0
File Interpreter ABI Platform Actions
arabic_repair-0.1.0-py3-none-any.whl Python 3 none any Details for arabic_repair-0.1.0-py3-none-any.whl

Total release size: 13.8 kB

Release files / arabic_repair-0.1.0.tar.gz

Download URL arabic_repair-0.1.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f0898f238c083053393fa89c514875939a7e7b81a0299422bd40c213180b7b47
BLAKE2b-256 checksum
How to use checksums
166755245d10e3903ef09fffe11c3e4b5c139b72c641e508ff6ff067b2cb0f86
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 4, 2026.

Transparency log

Release files / arabic_repair-0.1.0-py3-none-any.whl

Download URL arabic_repair-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e75a7da78761f2b6d5c26ba8b9611e5f5c7d9f68cc7fc3847c7eb55d0895ecb4
BLAKE2b-256 checksum
How to use checksums
7e81e0ef0a537d86f6f450c0428542c3e0f9e46b763d7462787f121b80f9f1b0
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 4, 2026.

Transparency log

Security for arabic-repair 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.

Select from 2 files

Attestation for arabic_repair-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 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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