Python package for normalizing Hassaniya Arabic text using variant mapping and letter-level rules.
- Normalizes known dialect variants to canonical forms.
- Applies letter rules in a deterministic order.
- Supports exception words that must not be transformed.
- Supports link fix mappings for known tokenization and linking issues.
- Includes a CLI for batch and stream processing.
- Includes a local web UI for paste-and-review workflows.
git clone https://github.com/Amin-tech99/hassaniya-normaliser.git
cd hassaniya-normaliser
python -m pip install .For development:
python -m pip install -e ".[dev]"Normalize a file:
hassy-normalize input.txt -o output.txtNormalize from stdin:
cat input.txt | hassy-normalize > output.txtShow inline diff for changes:
hassy-normalize input.txt --diff --colorRun local UI server:
hassy-normalize-ui --host 127.0.0.1 --port 8765Then open:
http://127.0.0.1:8765
UI features:
- Paste text and normalize instantly.
- Highlight changed words in the normalized output.
- Show change statistics (changed words, total words, percentage).
from hassy_normalizer import get_stats, normalize_text, normalize_word
text = "sample text"
print(normalize_text(text))
print(normalize_word("sample"))
print(get_stats())Normalization order:
- De-elongation (collapse noisy 3+ repeated Arabic letters)
- Link fixes from
linked_words.json - Variant lookup from
hassaniya_variants.jsonl - Letter rules from
rules.py(with exceptions inexception_words_g_q.json)
src/hassy_normalizer/
__init__.py
cli.py
data_loader.py
diff.py
normalizer.py
rules.py
web_ui/
data/
scripts/
validate_data.py
tests/
Run tests:
pytestValidate data files:
python scripts/validate_data.pyLint and format:
ruff check src tests
black src tests- Contribution guide: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security policy: SECURITY.md
MIT. See LICENSE.