arabic-normalizer 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,50 @@
1
+ """Lightweight Arabic text normalization."""
2
+ import re
3
+
4
+ __version__ = "0.1.0"
5
+
6
+ _DIACRITICS = re.compile(r"[\u0617-\u061A\u064B-\u0652\u0670]")
7
+ _ALEF = re.compile(r"[إأآٱ]")
8
+ _DIGITS = str.maketrans("٠١٢٣٤٥٦٧٨٩۰۱۲۳۴۵۶۷۸۹", "01234567890123456789")
9
+
10
+
11
+ def remove_diacritics(text: str) -> str:
12
+ """Remove tashkeel (fatha, damma, kasra, shadda, sukun...)."""
13
+ return _DIACRITICS.sub("", text)
14
+
15
+
16
+ def remove_tatweel(text: str) -> str:
17
+ """Remove tatweel (ـ) used for stretching words."""
18
+ return text.replace("\u0640", "")
19
+
20
+
21
+ def normalize_alef(text: str) -> str:
22
+ """Unify أ إ آ ٱ into ا."""
23
+ return _ALEF.sub("ا", text)
24
+
25
+
26
+ def normalize_yaa(text: str) -> str:
27
+ """Convert ى to ي."""
28
+ return text.replace("ى", "ي")
29
+
30
+
31
+ def normalize_taa_marbuta(text: str) -> str:
32
+ """Convert ة to ه."""
33
+ return text.replace("ة", "ه")
34
+
35
+
36
+ def convert_digits(text: str) -> str:
37
+ """Convert Arabic-Indic and Persian digits to 0-9."""
38
+ return text.translate(_DIGITS)
39
+
40
+
41
+ def normalize(text: str, taa_marbuta: bool = False) -> str:
42
+ """Apply all common normalization steps."""
43
+ text = remove_diacritics(text)
44
+ text = remove_tatweel(text)
45
+ text = normalize_alef(text)
46
+ text = normalize_yaa(text)
47
+ text = convert_digits(text)
48
+ if taa_marbuta:
49
+ text = normalize_taa_marbuta(text)
50
+ return " ".join(text.split())
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.5
2
+ Name: arabic-normalizer
3
+ Version: 0.1.0
4
+ Summary: Lightweight Arabic text normalization for search and NLP
5
+ Project-URL: Homepage, https://github.com/azizalkhayal-netizen/arabic-normalizer
6
+ Author: Abdulaziz Alkhayyal
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: arabic,nlp,normalization,text
10
+ Classifier: Natural Language :: Arabic
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Topic :: Text Processing :: Linguistic
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+
16
+ # arabic-normalizer
17
+
18
+ A lightweight Python library for cleaning and normalizing Arabic text, with no dependencies.
19
+
20
+ ## Installation
21
+ ```
22
+ pip install arabic-normalizer
23
+ ```
24
+
25
+ ## Features
26
+ - Remove diacritics (tashkeel) and tatweel
27
+ - Unify alef forms (أ إ آ → ا) and ى → ي
28
+ - Convert Arabic-Indic digits (٠١٢) to 0-9
29
+ - Optional ة → ه normalization
30
+
31
+ ## Usage
32
+ ```python
33
+ from arabic_normalizer import normalize
34
+
35
+ normalize("أَهْلاً بِكُمْ فِي الرِّيَاضِ ٢٠٢٦")
36
+ # 'اهلا بكم في الرياض 2026'
37
+ ```
38
+
39
+ ## License
40
+ MIT
@@ -0,0 +1,5 @@
1
+ arabic_normalizer/__init__.py,sha256=rKuI_NrBSThOyYlHAC8lVlpfwZQnueHFnW9RpYWmTIY,1377
2
+ arabic_normalizer-0.1.0.dist-info/METADATA,sha256=IlYeDTn3bgZ3kvGW2yLLhqU4z79ovRDkMC_o2VLqJXA,1084
3
+ arabic_normalizer-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
4
+ arabic_normalizer-0.1.0.dist-info/licenses/LICENSE,sha256=f4vAra0J7E3gx4U-PNopqij07IHdU-H_V9FRJSTTF08,1077
5
+ arabic_normalizer-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 azizalkhayal-netizen
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.