masri-normalize
مكتبة بايثون صغيرة بتنضّف وتطبّع النص المصري (العامية) قبل ما تدخّله في نماذج الذكاء الاصطناعي أو معالجة اللغة: تشكيل، تطويل، حروف مكررة، أرقام عربية، وعربيزي.
A small Python library that cleans and normalizes Egyptian Arabic text (diacritics, tatweel, repeated letters, Arabic digits, Arabizi) before feeding it to AI/NLP models.
ليه؟
النص المصري اللي بنكتبه كل يوم مليان حاجات بتبوّظ النماذج:
- تشكيل وتطويل:
مُحَمَّد،مـــرحبا - تكرار حروف للتأكيد:
جمااااال - أرقام عربية:
١٢٣ - عربيزي:
7abibi - لينكات ومنشن وإيموجي:
شوف https://x.com عند @ahmed 😂
المكتبة دي بتظبط كل ده في سطر واحد.
التثبيت
pip install masri-normalize
أو من الكود مباشرة:
git clone https://github.com/cmse66-dotcom/masri-normalize.git
cd masri-normalize
pip install .
الاستخدام
from masri_normalize import normalize
normalize("أهلاً بالـــــزماااائل ١٢٣")
# 'اهلا بالزماائل 123'
normalize("7abibi عامل ايه")
# 'حabibi عامل ايه'
normalize("شوف https://example.com عند @ahmed 😂")
# 'شوف عند'
كل خطوة تقدر تقفلها بمفتاح:
normalize("مدرسة") # 'مدرسة' (التاء المربوطة بتفضل زي ما هي)
normalize("مدرسة", ta_marbuta=True) # 'مدرسه'
normalize("مـــرحبا", tatweel=False) # 'مـــرحبا'
normalize("جماااال", max_repeat=1) # 'جمال'
أو استخدم أي دالة لوحدها:
from masri_normalize import (
remove_diacritics, remove_tatweel, normalize_alef, normalize_ya,
normalize_ta_marbuta, normalize_digits, reduce_repeated_chars,
arabizi_digits_to_arabic, clean_text,
)
remove_diacritics("مُحَمَّد") # 'محمد'
remove_tatweel("مـــرحبا") # 'مرحبا'
normalize_alef("أحمد إبراهيم") # 'احمد ابراهيم'
normalize_ya("على") # 'علي'
normalize_digits("١٢٣") # '123'
reduce_repeated_chars("جماااال") # 'جماال'
clean_text("يا #مصر 😂") # 'يا مصر'
ملاحظات مهمة
- العربيزي تحويل تقريبي: الأرقام (2, 3, 5, 7, 8) بتتبدل بالحروف المشهورة (ء، ع، خ، ح، غ) جوه الكلمات اللي فيها حروف لاتينية. مش ترجمة كاملة، لكنه بيفيد كخطوة أولى. أرقام التليفونات والكميات متتأثرش.
- التاء المربوطة مقفولة افتراضياً لأنها بتغيّر شكل الكلمة. شغّلها بس لو بتجهّز نص للبحث أو المطابقة، مش للعرض.
- تكرار الحروف بيتقلّص لـ 2 مش 1 عشان يحافظ على التأكيد الشائع في المصري (
جميييل->جمييل).
التطوير
شغّل الاختبارات:
python -m unittest discover -s tests -v
وشغّل الأمثلة:
python examples/basic_usage.py
المساهمة
أي مساهمة مرحب بيها: Issues للمشاكل والاقتراحات، وPull Requests للتحسينات. لو عندك كلمة عربيزي أو حالة المكتبة بتغلط فيها، ابعتهالنا.
الترخيص
MIT — شوف ملف LICENSE.
English summary
masri-normalize normalizes Egyptian Arabic text for NLP pipelines: strips diacritics and tatweel, unifies alef/ya forms, optionally converts ta marbuta, converts Eastern Arabic/Persian digits to ASCII, replaces common Arabizi digits inside Latin-script words (2, 3, 5, 7, 8), collapses repeated characters (default max 2 to keep emphasis), and cleans URLs, mentions, hashtags, and emoji. Everything is toggleable via keyword arguments. No dependencies, Python 3.8+.
Metadata
Release files for masri-normalize 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 |
|---|---|---|---|---|
| masri_normalize-0.1.0.tar.gz | 7.5 kB | Without provenance | Details for masri_normalize-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| masri_normalize-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for masri_normalize-0.1.0-py3-none-any.whl |
Total release size: 14.8 kB
Release files / masri_normalize-0.1.0.tar.gz
| Download URL | masri_normalize-0.1.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9c42d9f90eb637d0b34cccf5d27303a09a6cfd65ae880879bb742292a776188
|
|
BLAKE2b-256 checksum How to use checksums |
ed7513301fe7e4d0348e486cade716b1825d3fde86625fd50c4a005fe33b54ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Release files / masri_normalize-0.1.0-py3-none-any.whl
| Download URL | masri_normalize-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ccb74b94bb430ca20777f0e9dacd17e1633179aae9a414c694f89bf06c4ca6e
|
|
BLAKE2b-256 checksum How to use checksums |
3828706fcf56f893875b5afeb03674ab1f58005b2d4e257075ccfaf7131aa1b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.2
|
Security for masri-normalize 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.