Skip to main content

darija-tools

CI PyPI License: MIT

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

darija_tools-0.2.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

darija_tools-0.2.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

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

Hashes for darija_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8a8c28af29e41ffb2f874a7c5c017c35cae1872fb29cf9a20d72ed9660b86290
MD5 3d112d15d19b632990b756b5e4a788c8
BLAKE2b-256 55767473908e5e54f9d0b61585b8657342699968a5e6bd4acfd887f5c246faf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for darija_tools-0.2.0.tar.gz:

Publisher: publish.yml on Samielakkad/darija-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for darija_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2937c583457a85d6cbe3cc158af0d615a2ef6204d0fdf653aeadcf049f96c9ee
MD5 9fa734201c83dbade890ae56050e7f4c
BLAKE2b-256 f7f3b5fcb30617406b0c56c603c04b9707be0dfa9b3bc83ab12f5487766264ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for darija_tools-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Samielakkad/darija-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page