shamy-arabic-nlp
Pure Python (no dependencies) Arabic toolkit by Omar Elshamy. MIT.
- Normalizer: remove tashkeel and tatweel, unify alef forms, Arabic-Indic digits to 0-9, Arabic punctuation, squeeze stretched letters.
- Arabizi to Arabic: converts chat Arabic like
ezayak ya 7abibitoازيك يا حبيبي(digits 2 3 5 6 7 8 9, digraphs sh kh gh th dh, definite article, a lexicon of common words). - Dialect classifier baseline: Naive Bayes on word and character n-grams for MSA, Egyptian, Gulf, Levantine, Maghrebi. Trainable on your own data.
شامي للغة العربية
مكتبة بايثون بدون اعتماديات، من تطوير عمر الشامي، رخصة MIT. تحتوي على: (1) توحيد النص العربي (حذف التشكيل والتطويل وتوحيد الألف وتحويل الأرقام)، (2) تحويل الفرانكو/العربيزي إلى حروف عربية، (3) نموذج أساسي لتصنيف اللهجة (فصحى، مصري، خليجي، شامي، مغاربي).
Install / التثبيت
pip install .
Use / الاستخدام
from shamy_arabic import normalize, arabizi_to_arabic, is_arabizi, predict_dialect, DialectClassifier
normalize("أَحْمَد جداااا ٣") # 'احمد جدا 3'
arabizi_to_arabic("ezayak ya 7abibi") # 'ازيك يا حبيبي'
is_arabizi("ana 3ayez a2ol 7aga") # True
predict_dialect("ازيك يا باشا عامل ايه") # 'EGY'
clf = DialectClassifier().fit([("نص", "EGY"), ...]) # train on your own data
clf.predict_proba("..."); clf.save("m.json")
Honest limits / حدود صريحة
- Arabizi is ambiguous: short vowels are not written, so
kitabcould be many words. The converter uses a lexicon for common words and letter rules otherwise. Expect good results on common chat words, rough results elsewhere. ExtendLEXICONinarabizi.py. - The dialect model is a toy baseline. It is trained on about 100 short original sentences written for this repo (
_corpus.py), and tested on 15 held-out ones. High held-out accuracy there does NOT mean it works on real social media text. For real use, retrain on a proper dataset (for example MADAR or NADI, check their licences) withDialectClassifier().fit(...). - Normalization keeps ى/ي and ة/ه by default; switch them on with
ya=True,ta_marbuta=True.
Test
pip install pytest
pytest
Metadata
Release files for shamy-arabic-nlp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shamy_arabic_nlp-0.1.0.tar.gz | 13.3 kB | Without provenance | Details for shamy_arabic_nlp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shamy_arabic_nlp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for shamy_arabic_nlp-0.1.0-py3-none-any.whl |
Total release size: 25.4 kB
Release files / shamy_arabic_nlp-0.1.0.tar.gz
| Download URL | shamy_arabic_nlp-0.1.0.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1394e0843bd09cbdb06c206e665657ee7b3979720f88c23f0d0ca020053d2ab1
|
|
BLAKE2b-256 checksum How to use checksums |
646dd1fce75208e14103b3b4e9feeccb6c78f325483e5c3cc941518d5d51a5da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / shamy_arabic_nlp-0.1.0-py3-none-any.whl
| Download URL | shamy_arabic_nlp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
62273ff2f903ebaf47de928a024dddf8208e61288558d3e16b8ad1793ca65774
|
|
BLAKE2b-256 checksum How to use checksums |
68d83d20ff12bd299d626cae994ee25a9c331b74085486d7f7ef4777ea587b82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for shamy-arabic-nlp 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.