trk-mmr-tools
PDF extraction, Arabic text correction, and WordBank tools
Description
trk-mmr-tools provides a streamlined workflow for handling complex Arabic document processing and automated text cleanup. It specializes in:
- Hybrid PDF Extraction: High-performance text extraction using PyMuPDF with an automatic OCR fallback via Tesseract.
- Arabic Text Normalization: Advanced cleaning and correction tailored for Arabic script.
- WordBank Integration: Automated spell-checking and dictionary-based validation using high-performance indexing for large datasets.
It is designed for researchers, developers, and data scientists processing Arabic PDFs for NLP, media ethnography, or building academic word databases.
Prerequisites
This package is a Python wrapper for the Tesseract OCR engine. You must install the engine on your operating system for the OCR features to work:
- Ubuntu / Google Colab:
sudo apt-get update sudo apt-get install tesseract-ocr tesseract-ocr-ara
* **macOS:**
```bash
brew install tesseract tesseract-lang
```
* **Windows:** Download the installer from [UB Mannheim](https://www.google.com/search?q=https://github.com/UB-Mannheim/tesseract/wiki). Ensure you check the box for **Arabic** script data during installation and add the Tesseract directory to your System PATH.
-----
## Installation
```bash
# Using pip
pip install trk-mmr-tools
```
> **Note:** If you are using this in an environment with older versions of NumPy (like some versions of JAX or OpenCV), ensure you have **NumPy 1.26.0 or higher**.
-----
## Usage
The following example demonstrates how to process a PDF (or a folder of PDFs) using the OCR method with Arabic language support and WordBank corrections.
```python
from pathlib import Path
from trk_mmr_tools.pdf.processor import process_pdfs
from trk_mmr_tools.text.correction import TextCorrection
# Define input and output paths
pdf_input = Path("tests/sample.pdf") # Can be a file or a directory
output_dir = Path("output")
output_dir.mkdir(exist_ok=True)
# Initialize the Arabic text corrector (loads WordBank assets)
corrector = TextCorrection()
# Process the PDFs
process_pdfs(
source=pdf_input,
output_dir=output_dir,
method="ocr", # Uses Tesseract for scanned/image-based PDFs
lang="ara", # Specifies Arabic language for OCR
clean=True, # Normalizes characters and removes noise
corrector=corrector # Applies the dictionary-based validator
)
```
-----
## Project Structure
For your custom WordBank and assets to be recognized, ensure your package follows this structure:
```text
trk-mmr-tools/
├── pyproject.toml
├── README.md
└── src/
└── trk_mmr_tools/
├── __init__.py
├── pdf/
├── text/
└── assets/
├── bank.pkl
└── data.xlsx
```
-----
## License
MIT License
## Author
**Tarek**
Metadata
Release files for trk-mmr-tools 0.2.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 |
|---|---|---|---|---|
| trk_mmr_tools-0.2.0.tar.gz | 2.1 MB | Without provenance | Details for trk_mmr_tools-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| trk_mmr_tools-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for trk_mmr_tools-0.2.0-py3-none-any.whl |
Total release size: 4.2 MB
Release files / trk_mmr_tools-0.2.0.tar.gz
| Download URL | trk_mmr_tools-0.2.0.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14be0acfc4edd616f121cfcddc98d9c237cb28036039fe65fad204f1e866400b
|
|
BLAKE2b-256 checksum How to use checksums |
746cc93b2e22494da4b0cffa883bb9795d827cb9c59d2ae4cc8387980ff662c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / trk_mmr_tools-0.2.0-py3-none-any.whl
| Download URL | trk_mmr_tools-0.2.0-py3-none-any.whl |
|---|---|
| Size | 2.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3ea0b64744a4c27631fc2321ec014a3e139f0b9ebd11aef3dd9a940f1a3b18f
|
|
BLAKE2b-256 checksum How to use checksums |
c564a9c0c89ef32f04843de5877073257b730f176779b39a23b7d6876e070b40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for trk-mmr-tools 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.