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.1.tar.gz (14.1 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.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file darija_tools-0.2.1.tar.gz.

File metadata

  • Download URL: darija_tools-0.2.1.tar.gz
  • Upload date:
  • Size: 14.1 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.1.tar.gz
Algorithm Hash digest
SHA256 6d9da6d1757c3df9fc0c22846ec5dee0f5b92f59e68bc82a5d7d17c1dda8a2ad
MD5 abc572b9cf7d305384e1cc69d7bee805
BLAKE2b-256 da5f28137e05aab2defe07d456ece3759c206f4dfcd0357c26f57d53b38e4775

See more details on using hashes here.

Provenance

The following attestation bundles were made for darija_tools-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: darija_tools-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97a85ad2e24612fccc4d9519c819944f6ce4523c8795144ac89861251bf3a472
MD5 6a40eb773b75602427fa2e29550114e5
BLAKE2b-256 431736cc2e1fc1cba41ee3888b679b80fe38e070ba2a42c6346674eedee817a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for darija_tools-0.2.1-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