Two small libraries around the same problem: Darija is not a cleaned-up Arabic, and generic string metrics treat it that way.
DarijaDistance
DarijaDistance is a Python library for the actual linguistic mess of Moroccan Darija: comparison, distance, translation lookup, confidence, exact matches. It exists because Levenshtein on Latin-script Darija is a poor proxy for “did this speaker mean the same word?”
DarijaTranslatorAssistant
DarijaTranslatorAssistant sits on top of that. It does two jobs:
- Assisted translation — candidate translations for a Darija word or sentence, using the custom distance algorithm when the match is ambiguous.
- LLM client — talk to any hosted language model, with a built-in path for OpenAI if you pass a key and a model name.
The useful part is not “call GPT.” It is the combination: cache, normalisation, distance, then a model if you still need one.
Both packages are on PyPI. If you work on Moroccan NLP, start here before you fine-tune anything.