aranorm 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aranorm-1.2.0/LICENSE +21 -0
- aranorm-1.2.0/PKG-INFO +437 -0
- aranorm-1.2.0/README.md +370 -0
- aranorm-1.2.0/pyproject.toml +158 -0
- aranorm-1.2.0/setup.cfg +23 -0
- aranorm-1.2.0/src/aranorm/__init__.py +117 -0
- aranorm-1.2.0/src/aranorm/analysis/__init__.py +33 -0
- aranorm-1.2.0/src/aranorm/analysis/corpus_analyzer.py +352 -0
- aranorm-1.2.0/src/aranorm/analysis/keyword_extractor.py +180 -0
- aranorm-1.2.0/src/aranorm/analysis/readability.py +358 -0
- aranorm-1.2.0/src/aranorm/analysis/sentiment_analyzer.py +399 -0
- aranorm-1.2.0/src/aranorm/analysis/summarizer.py +302 -0
- aranorm-1.2.0/src/aranorm/analysis/text_analyzer.py +236 -0
- aranorm-1.2.0/src/aranorm/analysis/text_comparator.py +330 -0
- aranorm-1.2.0/src/aranorm/cli.py +734 -0
- aranorm-1.2.0/src/aranorm/core/__init__.py +23 -0
- aranorm-1.2.0/src/aranorm/core/base.py +129 -0
- aranorm-1.2.0/src/aranorm/core/config.py +436 -0
- aranorm-1.2.0/src/aranorm/core/pipeline.py +625 -0
- aranorm-1.2.0/src/aranorm/core/registry.py +122 -0
- aranorm-1.2.0/src/aranorm/core/stop_words_config.py +107 -0
- aranorm-1.2.0/src/aranorm/core/stop_words_registry.py +301 -0
- aranorm-1.2.0/src/aranorm/data/arabizi_mappings.json +124 -0
- aranorm-1.2.0/src/aranorm/data/chat_abbreviations.json +40 -0
- aranorm-1.2.0/src/aranorm/data/dialect_mappings.json +311 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/arabizi.txt +22 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/domains/academic.txt +55 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/domains/legal.txt +84 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/domains/medical.txt +72 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/domains/news.txt +78 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/domains/religious.txt +78 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/egy.txt +118 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/filler.txt +103 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/glf.txt +80 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/internet.txt +152 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/irq.txt +43 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/lev.txt +51 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/msa.txt +715 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/nor.txt +46 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/numbers.txt +10 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/phrases.txt +91 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/sdn.txt +97 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/social_media.txt +58 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/tun.txt +48 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/universal.txt +2449 -0
- aranorm-1.2.0/src/aranorm/data/stopwords/yem.txt +40 -0
- aranorm-1.2.0/src/aranorm/data/stopwords_categorized.json +461 -0
- aranorm-1.2.0/src/aranorm/exceptions/__init__.py +27 -0
- aranorm-1.2.0/src/aranorm/exceptions/errors.py +61 -0
- aranorm-1.2.0/src/aranorm/integrations/__init__.py +15 -0
- aranorm-1.2.0/src/aranorm/integrations/huggingface_integration.py +165 -0
- aranorm-1.2.0/src/aranorm/integrations/nltk_stopwords.py +185 -0
- aranorm-1.2.0/src/aranorm/integrations/pandas_integration.py +171 -0
- aranorm-1.2.0/src/aranorm/integrations/sklearn_stopwords.py +41 -0
- aranorm-1.2.0/src/aranorm/integrations/spacy_stopwords.py +71 -0
- aranorm-1.2.0/src/aranorm/models/__init__.py +7 -0
- aranorm-1.2.0/src/aranorm/models/_transformers_model.py +143 -0
- aranorm-1.2.0/src/aranorm/models/coda_model.py +66 -0
- aranorm-1.2.0/src/aranorm/models/dialect_id_model.py +31 -0
- aranorm-1.2.0/src/aranorm/models/msa_model.py +61 -0
- aranorm-1.2.0/src/aranorm/processors/__init__.py +104 -0
- aranorm-1.2.0/src/aranorm/processors/_base.py +39 -0
- aranorm-1.2.0/src/aranorm/processors/alef_processor.py +24 -0
- aranorm-1.2.0/src/aranorm/processors/arabizi_processor.py +56 -0
- aranorm-1.2.0/src/aranorm/processors/arabizi_stop_processor.py +48 -0
- aranorm-1.2.0/src/aranorm/processors/context_aware_processor.py +112 -0
- aranorm-1.2.0/src/aranorm/processors/currency_processor.py +129 -0
- aranorm-1.2.0/src/aranorm/processors/date_processor.py +140 -0
- aranorm-1.2.0/src/aranorm/processors/diacritics_processor.py +14 -0
- aranorm-1.2.0/src/aranorm/processors/dialect_stop_processor.py +56 -0
- aranorm-1.2.0/src/aranorm/processors/digits_processor.py +18 -0
- aranorm-1.2.0/src/aranorm/processors/domain_stop_processor.py +95 -0
- aranorm-1.2.0/src/aranorm/processors/emoji_processor.py +23 -0
- aranorm-1.2.0/src/aranorm/processors/hamza_processor.py +15 -0
- aranorm-1.2.0/src/aranorm/processors/internet_stop_processor.py +48 -0
- aranorm-1.2.0/src/aranorm/processors/ligatures_processor.py +21 -0
- aranorm-1.2.0/src/aranorm/processors/morphological_stop_processor.py +141 -0
- aranorm-1.2.0/src/aranorm/processors/normalization_processor.py +133 -0
- aranorm-1.2.0/src/aranorm/processors/number_words_processor.py +208 -0
- aranorm-1.2.0/src/aranorm/processors/phone_processor.py +78 -0
- aranorm-1.2.0/src/aranorm/processors/phrase_stop_processor.py +150 -0
- aranorm-1.2.0/src/aranorm/processors/platform_processors.py +177 -0
- aranorm-1.2.0/src/aranorm/processors/punctuation_processor.py +14 -0
- aranorm-1.2.0/src/aranorm/processors/repeated_chars_processor.py +22 -0
- aranorm-1.2.0/src/aranorm/processors/spacing_processor.py +27 -0
- aranorm-1.2.0/src/aranorm/processors/spelling_processor.py +143 -0
- aranorm-1.2.0/src/aranorm/processors/stop_words_processor.py +203 -0
- aranorm-1.2.0/src/aranorm/processors/taa_marbuta_processor.py +13 -0
- aranorm-1.2.0/src/aranorm/processors/tatweel_processor.py +13 -0
- aranorm-1.2.0/src/aranorm/processors/text_cleaning_processors.py +92 -0
- aranorm-1.2.0/src/aranorm/processors/unicode_processor.py +15 -0
- aranorm-1.2.0/src/aranorm/processors/whitespace_processor.py +15 -0
- aranorm-1.2.0/src/aranorm/py.typed +0 -0
- aranorm-1.2.0/src/aranorm/stages/__init__.py +33 -0
- aranorm-1.2.0/src/aranorm/stages/cleaner.py +55 -0
- aranorm-1.2.0/src/aranorm/stages/dialect_id.py +212 -0
- aranorm-1.2.0/src/aranorm/stages/dialect_norm.py +243 -0
- aranorm-1.2.0/src/aranorm/stages/morphological.py +31 -0
- aranorm-1.2.0/src/aranorm/stages/normalizer.py +72 -0
- aranorm-1.2.0/src/aranorm/stages/stop_words_stage.py +71 -0
- aranorm-1.2.0/src/aranorm/utils/__init__.py +99 -0
- aranorm-1.2.0/src/aranorm/utils/cache.py +210 -0
- aranorm-1.2.0/src/aranorm/utils/chunker.py +213 -0
- aranorm-1.2.0/src/aranorm/utils/constants.py +176 -0
- aranorm-1.2.0/src/aranorm/utils/exporters.py +256 -0
- aranorm-1.2.0/src/aranorm/utils/helpers.py +22 -0
- aranorm-1.2.0/src/aranorm/utils/language_detector.py +329 -0
- aranorm-1.2.0/src/aranorm/utils/normalizer_utils.py +234 -0
- aranorm-1.2.0/src/aranorm/utils/patterns.py +30 -0
- aranorm-1.2.0/src/aranorm/utils/progress.py +187 -0
- aranorm-1.2.0/src/aranorm/utils/root_extractor.py +155 -0
- aranorm-1.2.0/src/aranorm/utils/stemmer.py +271 -0
- aranorm-1.2.0/src/aranorm/utils/text_stats.py +240 -0
- aranorm-1.2.0/src/aranorm/utils/tokenizer.py +275 -0
- aranorm-1.2.0/src/aranorm/utils/validators.py +17 -0
- aranorm-1.2.0/src/aranorm.egg-info/PKG-INFO +437 -0
- aranorm-1.2.0/src/aranorm.egg-info/SOURCES.txt +129 -0
- aranorm-1.2.0/src/aranorm.egg-info/dependency_links.txt +1 -0
- aranorm-1.2.0/src/aranorm.egg-info/entry_points.txt +2 -0
- aranorm-1.2.0/src/aranorm.egg-info/requires.txt +37 -0
- aranorm-1.2.0/src/aranorm.egg-info/top_level.txt +1 -0
- aranorm-1.2.0/tests/test_analysis.py +283 -0
- aranorm-1.2.0/tests/test_cli.py +121 -0
- aranorm-1.2.0/tests/test_new_features.py +627 -0
- aranorm-1.2.0/tests/test_new_processors.py +181 -0
- aranorm-1.2.0/tests/test_pipeline.py +262 -0
- aranorm-1.2.0/tests/test_pipeline_enhanced.py +192 -0
- aranorm-1.2.0/tests/test_processors.py +292 -0
- aranorm-1.2.0/tests/test_stages.py +224 -0
- aranorm-1.2.0/tests/test_utils.py +203 -0
aranorm-1.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AraNorm Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aranorm-1.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aranorm
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: Production-grade Arabic text normalization pipeline for Modern Standard Arabic and dialects.
|
|
5
|
+
Author-email: Abdulaziz Alqudimi <alqudimi@example.com>
|
|
6
|
+
Maintainer-email: Abdulaziz Alqudimi <alqudimi@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/Alqudimi/AraNorm
|
|
9
|
+
Project-URL: Repository, https://github.com/Alqudimi/AraNorm
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/Alqudimi/AraNorm/issues
|
|
11
|
+
Project-URL: Documentation, https://github.com/Alqudimi/AraNorm/blob/main/docs/API.md
|
|
12
|
+
Project-URL: Changelog, https://github.com/Alqudimi/AraNorm/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: arabic,nlp,normalization,dialects,coda,arabizi,text-processing,arabic-nlp,natural-language-processing,arabic-text
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Natural Language :: Arabic
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
28
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
29
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
30
|
+
Classifier: Typing :: Typed
|
|
31
|
+
Requires-Python: >=3.9
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
Provides-Extra: camel
|
|
35
|
+
Requires-Dist: camel-tools>=1.5.0; extra == "camel"
|
|
36
|
+
Provides-Extra: ml
|
|
37
|
+
Requires-Dist: transformers>=4.30.0; extra == "ml"
|
|
38
|
+
Requires-Dist: torch>=2.0.0; extra == "ml"
|
|
39
|
+
Requires-Dist: sentencepiece>=0.1.99; extra == "ml"
|
|
40
|
+
Provides-Extra: quality
|
|
41
|
+
Requires-Dist: black>=23.0.0; extra == "quality"
|
|
42
|
+
Requires-Dist: flake8>=6.0.0; extra == "quality"
|
|
43
|
+
Requires-Dist: mypy>=1.0.0; extra == "quality"
|
|
44
|
+
Requires-Dist: pytest>=7.0.0; extra == "quality"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "quality"
|
|
46
|
+
Provides-Extra: full
|
|
47
|
+
Requires-Dist: camel-tools>=1.5.0; extra == "full"
|
|
48
|
+
Requires-Dist: pyarabic>=0.6.0; extra == "full"
|
|
49
|
+
Requires-Dist: tnkeeh>=0.0.9; extra == "full"
|
|
50
|
+
Requires-Dist: tahdheeb>=0.1.1; extra == "full"
|
|
51
|
+
Requires-Dist: transformers>=4.30.0; extra == "full"
|
|
52
|
+
Requires-Dist: torch>=2.0.0; extra == "full"
|
|
53
|
+
Requires-Dist: sentencepiece>=0.1.99; extra == "full"
|
|
54
|
+
Requires-Dist: emoji>=2.0.0; extra == "full"
|
|
55
|
+
Requires-Dist: regex>=2023.0.0; extra == "full"
|
|
56
|
+
Requires-Dist: tqdm>=4.65.0; extra == "full"
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
59
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
60
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
61
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
62
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
63
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
64
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
65
|
+
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
66
|
+
Dynamic: license-file
|
|
67
|
+
|
|
68
|
+
# AraNorm
|
|
69
|
+
|
|
70
|
+
**مكتبة Python الاحترافية لتطبيع النصوص العربية بجميع لهجاتها**
|
|
71
|
+
|
|
72
|
+
> Production-grade Arabic text normalization for MSA, dialects, social media, and Arabizi.
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
76
|
+
│ ArabicNormalizationPipeline │
|
|
77
|
+
├─────────────────────────────────────────────────────────────┤
|
|
78
|
+
│ ContentCleaner → OrthographicNormalizer → DialectProc │
|
|
79
|
+
│ (URLs, HTML, (alef, hamza, diacritics, (identify, │
|
|
80
|
+
│ emojis, ...) tatweel, digits, ...) CODA, MSA) │
|
|
81
|
+
└─────────────────────────────────────────────────────────────┘
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## لماذا AraNorm؟
|
|
87
|
+
|
|
88
|
+
يعاني كل مشروع عربي NLP من نفس المشكلة: تجميع مكتبات متعددة (CAMeL Tools + PyArabic + tnkeeh...) بواجهات مختلفة ونتائج متناقضة. AraNorm تحل هذه المشكلة بواجهة برمجية واحدة نظيفة.
|
|
89
|
+
|
|
90
|
+
| الميزة | AraNorm core | Optional Extra |
|
|
91
|
+
|-----------------------------------------------|-----------|-----------------------------|
|
|
92
|
+
| Unicode + alef + hamza + taa marbuta + digits | ✅ | — |
|
|
93
|
+
| تشكيل + كشيدة + تطويل + ترقيم + مسافات | ✅ | — |
|
|
94
|
+
| URLs + emails + mentions + hashtags + HTML | ✅ | — |
|
|
95
|
+
| Emoji removal | ✅ | — |
|
|
96
|
+
| Twitter / WhatsApp / Chat normalizers | ✅ | — |
|
|
97
|
+
| Arabizi → Arabic conversion | ✅ | — |
|
|
98
|
+
| Repeated chars reduction (يااا→يا) | ✅ | — |
|
|
99
|
+
| تحديد اللهجة (heuristic) | ✅ | CAMeL Tools (`[camel]`) |
|
|
100
|
+
| تحديد اللهجة >90% (MADAR corpus) | — | CAMeL Tools |
|
|
101
|
+
| CODA/MSA تطبيع عصبي | — | Transformers (`[ml]`) |
|
|
102
|
+
| التحليل الصرفي | Adapter | Farasa / Qalsadi / CAMeL |
|
|
103
|
+
|
|
104
|
+
### مقارنة مع المكتبات الأخرى
|
|
105
|
+
|
|
106
|
+
| المكتبة | Pipeline | لهجات | Arabizi | Platform | Batch | No-ML core |
|
|
107
|
+
|-------------|:--------:|:------:|:--------:|:--------:|:-----:|:----------:|
|
|
108
|
+
| **AraNorm** | ✅ | ✅ 8+ | ✅ | ✅ | ✅ | ✅ |
|
|
109
|
+
| CAMeL Tools | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
110
|
+
| PyArabic | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
111
|
+
| tnkeeh | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## التثبيت
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pip install aranorm
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
تبعيات اختيارية:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pip install "aranorm[camel]" # CAMeL Tools — dialect ID بدقة >90%
|
|
125
|
+
pip install "aranorm[ml]" # Transformers + PyTorch — نماذج CODA/MSA
|
|
126
|
+
pip install "aranorm[full]" # كل شيء
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## الاستخدام السريع
|
|
132
|
+
|
|
133
|
+
### Preset جاهز
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
from aranorm import ArabicNormalizationPipeline, PipelineConfig
|
|
137
|
+
|
|
138
|
+
config = PipelineConfig(
|
|
139
|
+
preset="standard", # "light" | "standard" | "deep" | "social_media"
|
|
140
|
+
dialect_target="coda", # "none" | "coda" | "msa"
|
|
141
|
+
remove_diacritics=True,
|
|
142
|
+
normalize_hamza=True,
|
|
143
|
+
handle_arabizi=True,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
pipeline = ArabicNormalizationPipeline(config)
|
|
147
|
+
result = pipeline.process("أهـــلاً شلونك؟ https://t.co/abc 😊")
|
|
148
|
+
|
|
149
|
+
print(result.normalized_text) # → "اهلا شلونك؟"
|
|
150
|
+
print(result.dialect) # → "GLF"
|
|
151
|
+
print(result.dialect_confidence) # → 0.75
|
|
152
|
+
print(result.coda_text) # → "أهلاً كيف حالك؟"
|
|
153
|
+
print(result.is_msa) # → False
|
|
154
|
+
print(result.applied_steps) # → ['remove_urls', 'normalize_alef', ...]
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Builder Pattern (مخصص بالكامل)
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
pipeline = (
|
|
161
|
+
ArabicNormalizationPipeline.builder()
|
|
162
|
+
.add_cleaner(remove_urls=True, remove_emojis=True)
|
|
163
|
+
.add_normalizer(
|
|
164
|
+
normalize_alef=True,
|
|
165
|
+
normalize_hamza=True,
|
|
166
|
+
normalize_diacritics=True,
|
|
167
|
+
normalize_tatweel=True,
|
|
168
|
+
)
|
|
169
|
+
.add_dialect_processor(
|
|
170
|
+
identify=True,
|
|
171
|
+
normalize_to="coda",
|
|
172
|
+
supported_dialects=["EGY", "GLF", "LEV", "NOR"],
|
|
173
|
+
)
|
|
174
|
+
.build()
|
|
175
|
+
)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### معالجة دفعية
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
texts = ["نص1", "نص2", "نص3"]
|
|
182
|
+
results = pipeline.process_batch(texts, batch_size=32, n_workers=4)
|
|
183
|
+
for r in results:
|
|
184
|
+
print(r.normalized_text, r.dialect)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Processors منفردة
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from aranorm.processors import ALEFProcessor, HamzaProcessor, DiacriticsProcessor
|
|
191
|
+
|
|
192
|
+
ALEFProcessor().process("أحمد إبراهيم آمن ٱلله")
|
|
193
|
+
# → "احمد ابراهيم امن الله"
|
|
194
|
+
|
|
195
|
+
HamzaProcessor().process("سؤال شيئ")
|
|
196
|
+
# → "سءال شيء"
|
|
197
|
+
|
|
198
|
+
DiacriticsProcessor().process("مَرْحَبًا بِكُمْ")
|
|
199
|
+
# → "مرحبا بكم"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### معالجات المنصات
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from aranorm.processors import TwitterNormalizer, WhatsAppNormalizer, ChatNormalizer
|
|
206
|
+
|
|
207
|
+
# تويتر
|
|
208
|
+
TwitterNormalizer().process("RT @user: شلونك؟ #موضوع https://t.co/x")
|
|
209
|
+
# → "شلونك؟ موضوع"
|
|
210
|
+
|
|
211
|
+
# واتساب
|
|
212
|
+
WhatsAppNormalizer().process("انشالله الشغل يخلص بكره 🙏 *مهم*: اجتماع")
|
|
213
|
+
# → "إن شاء الله الشغل يخلص بكره 🙏 مهم: اجتماع"
|
|
214
|
+
|
|
215
|
+
# دردشة
|
|
216
|
+
ChatNormalizer().process("هههههههههه مضحك جداً")
|
|
217
|
+
# → "هه مضحك جداً"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## الـ Presets
|
|
223
|
+
|
|
224
|
+
| Preset | الوصف |
|
|
225
|
+
|----------------|--------------------------------------------------------------|
|
|
226
|
+
| `light` | تطبيع أساسي فقط. لا حاجة لأي تبعيات خارجية. أسرع preset. |
|
|
227
|
+
| `standard` | الافتراضي. alef + hamza + diacritics + urls + whitespace. |
|
|
228
|
+
| `deep` | كل شيء. + تكرار الحروف + تصحيح الترقيم. |
|
|
229
|
+
| `social_media` | مثالي لتويتر/إنستاغرام. URLs + mentions + emojis. |
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## اللهجات المدعومة
|
|
234
|
+
|
|
235
|
+
| الرمز | اللهجة |
|
|
236
|
+
|-------|--------------------------------------|
|
|
237
|
+
| `EGY` | مصرية |
|
|
238
|
+
| `GLF` | خليجية (السعودية، الإمارات، الكويت) |
|
|
239
|
+
| `LEV` | شامية (سوريا، لبنان، فلسطين، الأردن) |
|
|
240
|
+
| `IRQ` | عراقية |
|
|
241
|
+
| `NOR` | مغاربية (المغرب، الجزائر، ليبيا) |
|
|
242
|
+
| `TUN` | تونسية |
|
|
243
|
+
| `YEM` | يمنية |
|
|
244
|
+
| `MSA` | الفصحى |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## الأداء
|
|
249
|
+
|
|
250
|
+
| Preset | النصوص/الثانية |
|
|
251
|
+
|----------------|---------------|
|
|
252
|
+
| `light` | ~17,000 |
|
|
253
|
+
| `standard` | ~15,000 |
|
|
254
|
+
| `deep` | ~13,000 |
|
|
255
|
+
| `social_media` | ~12,000 |
|
|
256
|
+
|
|
257
|
+
*مقاس على Python 3.11 — جهاز واحد، خيط واحد.*
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## المعمارية
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
aranorm/
|
|
265
|
+
├── core/ # Pipeline, Config (dataclass), Base ABC, Registry
|
|
266
|
+
├── stages/ # ContentCleaner, OrthographicNormalizer, DialectIdentifier,
|
|
267
|
+
│ # DialectNormalizer, MorphologicalProcessor
|
|
268
|
+
├── processors/ # 20+ processors منفردون (Processor interface)
|
|
269
|
+
├── models/ # Lazy wrappers: CODAModel, MSAModel, DialectIDModel
|
|
270
|
+
├── utils/ # Constants, patterns (regex), validators, helpers
|
|
271
|
+
├── data/ # dialect_mappings.json, arabizi_mappings.json,
|
|
272
|
+
│ # chat_abbreviations.json
|
|
273
|
+
└── exceptions/ # AraNormError hierarchy
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## التطوير
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
git clone <repo>
|
|
282
|
+
cd aranorm
|
|
283
|
+
pip install -e ".[dev]"
|
|
284
|
+
|
|
285
|
+
# تشغيل الاختبارات
|
|
286
|
+
make test # كل الاختبارات مع تفاصيل
|
|
287
|
+
make test-fast # سريع بدون verbose
|
|
288
|
+
|
|
289
|
+
# جودة الكود
|
|
290
|
+
make lint # flake8
|
|
291
|
+
make format # black
|
|
292
|
+
make type-check # mypy
|
|
293
|
+
|
|
294
|
+
# بنشمارك
|
|
295
|
+
make benchmark # 1000 نص
|
|
296
|
+
make benchmark-quick # 100 نص فقط
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Stop Words Support (جديد — v1.1)
|
|
304
|
+
|
|
305
|
+
نظام متكامل لكلمات التوقف العربية يدعم الفصحى (MSA) و8 لهجات والمحتوى العصري.
|
|
306
|
+
|
|
307
|
+
### Quick Start
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
from aranorm import ArabicNormalizationPipeline, PipelineConfig, StopWordsConfig
|
|
311
|
+
|
|
312
|
+
config = PipelineConfig(
|
|
313
|
+
preset="standard",
|
|
314
|
+
stop_words_config=StopWordsConfig(
|
|
315
|
+
mode="remove",
|
|
316
|
+
scope="dialect_aware",
|
|
317
|
+
dialects=frozenset(["EGY", "GLF"]),
|
|
318
|
+
preserve_negation=True,
|
|
319
|
+
remove_filler=True,
|
|
320
|
+
),
|
|
321
|
+
)
|
|
322
|
+
pipeline = ArabicNormalizationPipeline(config)
|
|
323
|
+
result = pipeline.process("أنا والله يعني سعيد جداً اليوم")
|
|
324
|
+
|
|
325
|
+
print(result.stop_words_removed) # → "سعيد"
|
|
326
|
+
print(result.stop_words_found) # → {"أنا", "والله", "يعني", "جداً", "اليوم"}
|
|
327
|
+
print(result.stop_words_stats) # → {count: 5, percentage: 71.4, by_category: {...}}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Modes
|
|
331
|
+
|
|
332
|
+
| Mode | الوصف |
|
|
333
|
+
|-------------|------------------------------------------------|
|
|
334
|
+
| `remove` | إزالة stop words من النص (الافتراضي) |
|
|
335
|
+
| `extract` | استخراج stop words فقط |
|
|
336
|
+
| `highlight` | وضع علامة `[[…]]` على stop words |
|
|
337
|
+
| `count` | إحصاء فقط بدون تعديل النص |
|
|
338
|
+
|
|
339
|
+
### Scopes
|
|
340
|
+
|
|
341
|
+
| Scope | الوصف |
|
|
342
|
+
|------------------|-------------------------------------------|
|
|
343
|
+
| `universal` | كل stop words (MSA + لهجات + عصرية) |
|
|
344
|
+
| `msa_only` | الفصحى فقط |
|
|
345
|
+
| `dialect_aware` | MSA + لهجات محددة |
|
|
346
|
+
| `custom` | قائمة مخصصة فقط |
|
|
347
|
+
|
|
348
|
+
### اللهجات المدعومة
|
|
349
|
+
|
|
350
|
+
`EGY` (مصرية) · `GLF` (خليجية) · `LEV` (شامية) · `IRQ` (عراقية) ·
|
|
351
|
+
`NOR` (مغاربية) · `TUN` (تونسية) · `YEM` (يمنية) · `MSA` (فصحى)
|
|
352
|
+
|
|
353
|
+
### المعالجات المنفردة
|
|
354
|
+
|
|
355
|
+
```python
|
|
356
|
+
from aranorm.processors import (
|
|
357
|
+
StopWordsProcessor, # المعالج الرئيسي (remove/extract/highlight/count)
|
|
358
|
+
ContextAwareProcessor, # إزالة ذكية حسب السياق (لا النافية / إن التوكيدية)
|
|
359
|
+
DialectStopProcessor, # إزالة لهجية
|
|
360
|
+
ArabiziStopProcessor, # إزالة Arabizi (2na، 3nd …)
|
|
361
|
+
InternetStopProcessor, # إزالة رموز الإنترنت (lol، www …)
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
# Context-aware: احتفظ بـ "لا" النافية
|
|
365
|
+
from aranorm.processors import ContextAwareProcessor
|
|
366
|
+
proc = ContextAwareProcessor(preserve_negation=True)
|
|
367
|
+
proc.process("لا أحب هذا") # → "لا أحب هذا" (لا محفوظة)
|
|
368
|
+
proc.process("لا شك في ذلك") # → "شك" (لا شك = مصطلح → أزلت)
|
|
369
|
+
|
|
370
|
+
# Dialect-aware
|
|
371
|
+
from aranorm.processors import DialectStopProcessor
|
|
372
|
+
proc = DialectStopProcessor(dialects=["EGY", "GLF"])
|
|
373
|
+
proc.process("أنا كده الحين سعيد") # → "سعيد"
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### StopWordsRegistry — البحث O(m) بالـ Trie
|
|
377
|
+
|
|
378
|
+
```python
|
|
379
|
+
from aranorm import StopWordsRegistry
|
|
380
|
+
|
|
381
|
+
registry = StopWordsRegistry()
|
|
382
|
+
|
|
383
|
+
registry.is_stop("من") # True (MSA)
|
|
384
|
+
registry.is_stop("كده", dialect="EGY") # True (مصرية)
|
|
385
|
+
registry.is_stop("كده", dialect="GLF") # False (ليست خليجية)
|
|
386
|
+
registry.is_stop("2na", is_arabizi=True) # True (Arabizi)
|
|
387
|
+
|
|
388
|
+
registry.get_by_category("prepositions") # {"في", "من", "إلى", ...}
|
|
389
|
+
registry.get_by_category("filler") # {"يعني", "والله", ...}
|
|
390
|
+
registry.get_stats() # {total_universal: 2449, msa: 715, egy: 65, ...}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### التكاملات مع مكتبات NLP
|
|
394
|
+
|
|
395
|
+
```python
|
|
396
|
+
from aranorm.integrations import (
|
|
397
|
+
NLTKStopWordsAdapter, # توافق NLTK
|
|
398
|
+
SpacyStopWordsAdapter, # توافق spaCy
|
|
399
|
+
SklearnStopWordsAdapter, # توافق scikit-learn
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
# scikit-learn
|
|
403
|
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
404
|
+
adapter = SklearnStopWordsAdapter()
|
|
405
|
+
vectorizer = TfidfVectorizer(stop_words=list(adapter.to_sklearn_set()))
|
|
406
|
+
|
|
407
|
+
# NLTK
|
|
408
|
+
adapter = NLTKStopWordsAdapter()
|
|
409
|
+
nltk_words = adapter.to_nltk_list() # قائمة مرتبة
|
|
410
|
+
|
|
411
|
+
# spaCy
|
|
412
|
+
adapter = SpacyStopWordsAdapter()
|
|
413
|
+
nlp = adapter.enrich_spacy(nlp) # يضيف كلمات التوقف لنموذج spaCy
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### الـ Presets الجاهزة
|
|
417
|
+
|
|
418
|
+
```python
|
|
419
|
+
from aranorm import StopWordsConfig
|
|
420
|
+
|
|
421
|
+
# سوشيال ميديا: يزيل filler + internet + arabizi
|
|
422
|
+
cfg = StopWordsConfig.for_social_media()
|
|
423
|
+
|
|
424
|
+
# لهجة محددة
|
|
425
|
+
cfg = StopWordsConfig.for_dialect("EGY", "GLF")
|
|
426
|
+
|
|
427
|
+
# إحصاء فقط بدون تعديل
|
|
428
|
+
cfg = StopWordsConfig.count_only()
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
> **ملاحظة:** الـ preset `social_media` يفعّل إزالة filler + internet + Arabizi تلقائياً.
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## الرخصة
|
|
436
|
+
|
|
437
|
+
[MIT](LICENSE) — AraNorm Contributors, 2024
|