Metadata-Version: 2.4
Name: shamy-arabic-nlp
Version: 0.1.0
Summary: Arabic normalizer, Arabizi to Arabic converter and dialect classifier baseline. Pure Python. By Omar Elshamy.
Author: Omar Elshamy
License: MIT
Keywords: arabic,nlp,arabizi,dialect,egyptian
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# shamy-arabic-nlp

Pure Python (no dependencies) Arabic toolkit by Omar Elshamy. MIT.

1. **Normalizer**: remove tashkeel and tatweel, unify alef forms, Arabic-Indic digits to 0-9, Arabic punctuation, squeeze stretched letters.
2. **Arabizi to Arabic**: converts chat Arabic like `ezayak ya 7abibi` to `ازيك يا حبيبي` (digits 2 3 5 6 7 8 9, digraphs sh kh gh th dh, definite article, a lexicon of common words).
3. **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 / الاستخدام
```python
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 `kitab` could 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. Extend `LEXICON` in `arabizi.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) with `DialectClassifier().fit(...)`.
- Normalization keeps ى/ي and ة/ه by default; switch them on with `ya=True`, `ta_marbuta=True`.

## Test
```
pip install pytest
pytest
```
