Query.py is a simple command-line tool that allows you to query possible Arabic words off a random string from a pre-built JSON dictionary.
I generated one myself using this wordlist — special thanks to Jamal for providing it.
It helps identify possible Arabic words that can be formed from a given set of letters, which makes it useful for recognizing words that share the same root structure or letter order.
- Python 3.8+
- A valid dictionary file named
Dictionary.jsonin the same directory.
Example Dictionary.json:
{
"اخدعهي": [
"أخدعيه",
"يخادعه",
"يخدعها"
],
}python3 Query.py دخاعهيOutput:
['أخدعيه', 'يخادعه', 'يخدعها']
You can check multiple words at once:
python3 Query.py دخاعهي بعاللهد اغغغغغ
Output:
['أخدعيه', 'يخادعه', 'يخدعها']
['عبدالله']
اغغغغغ doesn't appear in the database
If you run it without any arguments:
python3 Query.pyIt will prompt you:
you need to enter at least one argument
Hint: Expected
Query.py <word1> , <word2>...
Example:
Query.py احمد
Query.py حامد احمد محمد
-
Normalization
Converts Aleph variants (آ, أ, إ) → ا.
Example:إحمد→احمد -
Key Generation
Sorts the word’s letters alphabetically to form a lookup key.
Example:- "احمد" → "احدم"
- "حامد" → "احدم"
→ both share the same key, so they’re recognized as related.
-
Dictionary Lookup
LoadsDictionary.jsononce, searches for each key, and prints the results.
- Add
--no-normalizeflag to disable Aleph normalization. - Add normalization for
ةtoة. - Add an option to save missing words for review.
- Combine
SetDictionary.py&Query.pyinto one program.
WordRecognize/
├── Query.py
├── ArabicWordsList.txt
├── Dictionary.json
└── README.md
I am a Computer Science sophomore at Prince Sultan University (PSU). If you’re interested, feel free to connect with me on Linkedin or visit my website