darija-tools
Small, dependency-free text utilities for Moroccan Darija (الدارجة). The rules and word lists are plain files that can be reviewed and tested.
Install
pip install darija-tools
Python 3.9 or newer is supported.
Use it
from darija_tools import normalize, to_arabic, to_arabizi
normalize("الأَحْمَر")
# 'الاحمر'
to_arabic("3lach bghiti daba")
# 'علاش بغيتي دبا'
to_arabizi("علاش بغيتي دبا")
# '3lach bghiti daba'
to_arabic() checks a curated Darija word list, then uses letter and digraph rules for unknown words. Set keep_loanwords=True to leave recognized French and English loanwords in Latin script:
to_arabic("bghit taxi", keep_loanwords=True)
# 'بغيت taxi'
to_arabizi() uses the same lexicon in reverse and chooses one stable spelling when a word has several valid Arabizi forms. Unknown Arabic words use a readable character mapping.
Command line
darija normalize "الأَحْمَر"
darija translit "3lach bghiti daba"
darija translit --keep-loanwords "bghit taxi"
darija arabizi "علاش بغيتي دبا"
Omit the text argument to read from standard input.
Evaluation
The v0.2 Arabizi-to-Arabic evaluation contains 30 phrases kept outside the unit tests:
- Phrase exact match: 26/30 (86.7%)
- Whitespace-token exact match: 61/66 (92.4%)
The dataset, full error report and evaluation script are checked in. CI regenerates the result and fails if the committed report differs.
This is a small, manually curated regression set, not a blinded study or a claim about all Darija text. The four failed phrases remain visible in the report.
Limits
- Arabizi spelling is not standardized, so transliteration is lossy in both directions.
- Character rules cannot reliably recover unwritten vowels, doubled consonants or word endings.
- Loanword preservation covers a small reviewed list and is opt-in.
- The target is Moroccan Darija; overlap with other Maghrebi dialects is incidental.
Development
python -m pip install -e ".[dev]"
python -m ruff check src tests evaluation
python -m pytest -q
python evaluation/run.py --check
python -m build
python -m twine check dist/*
See CONTRIBUTING.md before changing language rules or data. v0.2 changes are summarized in the release notes.
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file darija_tools-0.2.0.tar.gz.
File metadata
- Download URL: darija_tools-0.2.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a8c28af29e41ffb2f874a7c5c017c35cae1872fb29cf9a20d72ed9660b86290
|
|
| MD5 |
3d112d15d19b632990b756b5e4a788c8
|
|
| BLAKE2b-256 |
55767473908e5e54f9d0b61585b8657342699968a5e6bd4acfd887f5c246faf3
|
Provenance
The following attestation bundles were made for darija_tools-0.2.0.tar.gz:
Publisher:
publish.yml on Samielakkad/darija-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darija_tools-0.2.0.tar.gz -
Subject digest:
8a8c28af29e41ffb2f874a7c5c017c35cae1872fb29cf9a20d72ed9660b86290 - Sigstore transparency entry: 2250711281
- Sigstore integration time:
-
Permalink:
Samielakkad/darija-tools@d45ad08b1d33bd93f2f32fa7edcff25933c2d15e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Samielakkad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d45ad08b1d33bd93f2f32fa7edcff25933c2d15e -
Trigger Event:
release
-
Statement type:
File details
Details for the file darija_tools-0.2.0-py3-none-any.whl.
File metadata
- Download URL: darija_tools-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2937c583457a85d6cbe3cc158af0d615a2ef6204d0fdf653aeadcf049f96c9ee
|
|
| MD5 |
9fa734201c83dbade890ae56050e7f4c
|
|
| BLAKE2b-256 |
f7f3b5fcb30617406b0c56c603c04b9707be0dfa9b3bc83ab12f5487766264ba
|
Provenance
The following attestation bundles were made for darija_tools-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on Samielakkad/darija-tools
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
darija_tools-0.2.0-py3-none-any.whl -
Subject digest:
2937c583457a85d6cbe3cc158af0d615a2ef6204d0fdf653aeadcf049f96c9ee - Sigstore transparency entry: 2250711786
- Sigstore integration time:
-
Permalink:
Samielakkad/darija-tools@d45ad08b1d33bd93f2f32fa7edcff25933c2d15e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/Samielakkad
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d45ad08b1d33bd93f2f32fa7edcff25933c2d15e -
Trigger Event:
release
-
Statement type: