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.

Metadata

Release files for darija-tools 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darija-tools 0.2.1
File Size Uploaded
darija_tools-0.2.1.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for darija-tools 0.2.1
File Interpreter ABI Platform
darija_tools-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.2 kB

Release files / darija_tools-0.2.1.tar.gz

Download URL darija_tools-0.2.1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6d9da6d1757c3df9fc0c22846ec5dee0f5b92f59e68bc82a5d7d17c1dda8a2ad
BLAKE2b-256 checksum
How to use checksums
da5f28137e05aab2defe07d456ece3759c206f4dfcd0357c26f57d53b38e4775
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / darija_tools-0.2.1-py3-none-any.whl

Download URL darija_tools-0.2.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
97a85ad2e24612fccc4d9519c819944f6ce4523c8795144ac89861251bf3a472
BLAKE2b-256 checksum
How to use checksums
431736cc2e1fc1cba41ee3888b679b80fe38e070ba2a42c6346674eedee817a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page