arabickit 0.1.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.
- arabickit-0.1.0/LICENSE +9 -0
- arabickit-0.1.0/PKG-INFO +59 -0
- arabickit-0.1.0/README.md +43 -0
- arabickit-0.1.0/arabickit.egg-info/PKG-INFO +59 -0
- arabickit-0.1.0/arabickit.egg-info/SOURCES.txt +9 -0
- arabickit-0.1.0/arabickit.egg-info/dependency_links.txt +1 -0
- arabickit-0.1.0/arabickit.egg-info/entry_points.txt +2 -0
- arabickit-0.1.0/arabickit.egg-info/top_level.txt +1 -0
- arabickit-0.1.0/arabickit.py +55 -0
- arabickit-0.1.0/pyproject.toml +27 -0
- arabickit-0.1.0/setup.cfg +4 -0
arabickit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 episodely
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
arabickit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arabickit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Arabic text cleanup: tashkeel, letter variants, digits.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/arabickit
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/arabickit/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# arabickit
|
|
18
|
+
|
|
19
|
+
Small, dependency-free helpers to clean and normalize Arabic text before search, comparison, NLP or LLM prompts. Works as a library or a CLI.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from arabickit import clean, strip_tashkeel, digits_to_ascii
|
|
23
|
+
|
|
24
|
+
clean(" أَهْلاً بِكَ ١٢ ") # 'اهلا بك 12'
|
|
25
|
+
strip_tashkeel("بِسْمِ اللَّهِ") # 'بسم الله'
|
|
26
|
+
digits_to_ascii("٢٠٢٦") # '2026'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
echo "أَهْلاً بِكَ ١٢" | python arabickit.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pip install arabickit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or copy `arabickit.py` into your project, it has no dependencies.
|
|
40
|
+
|
|
41
|
+
## Functions
|
|
42
|
+
|
|
43
|
+
| Function | What it does |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `strip_tashkeel` | remove harakat and Quranic marks |
|
|
46
|
+
| `strip_tatweel` | remove kashida (ـ) |
|
|
47
|
+
| `normalize_letters` | أ إ آ ٱ -> ا, ى -> ي |
|
|
48
|
+
| `normalize_ta_marbuta` | ة -> ه (optional, lossy) |
|
|
49
|
+
| `digits_to_ascii` / `digits_to_arabic` | Arabic-Indic and Persian digits <-> 0-9 |
|
|
50
|
+
| `normalize_punct` | ، ؛ ؟ -> , ; ? |
|
|
51
|
+
| `clean` | the usual combination in one call |
|
|
52
|
+
|
|
53
|
+
Normalization is lossy by design (good for matching, not for display). Keep the original text if you need to show it.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python -m pytest
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
MIT licensed.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# arabickit
|
|
2
|
+
|
|
3
|
+
Small, dependency-free helpers to clean and normalize Arabic text before search, comparison, NLP or LLM prompts. Works as a library or a CLI.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from arabickit import clean, strip_tashkeel, digits_to_ascii
|
|
7
|
+
|
|
8
|
+
clean(" أَهْلاً بِكَ ١٢ ") # 'اهلا بك 12'
|
|
9
|
+
strip_tashkeel("بِسْمِ اللَّهِ") # 'بسم الله'
|
|
10
|
+
digits_to_ascii("٢٠٢٦") # '2026'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
echo "أَهْلاً بِكَ ١٢" | python arabickit.py
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pip install arabickit
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or copy `arabickit.py` into your project, it has no dependencies.
|
|
24
|
+
|
|
25
|
+
## Functions
|
|
26
|
+
|
|
27
|
+
| Function | What it does |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `strip_tashkeel` | remove harakat and Quranic marks |
|
|
30
|
+
| `strip_tatweel` | remove kashida (ـ) |
|
|
31
|
+
| `normalize_letters` | أ إ آ ٱ -> ا, ى -> ي |
|
|
32
|
+
| `normalize_ta_marbuta` | ة -> ه (optional, lossy) |
|
|
33
|
+
| `digits_to_ascii` / `digits_to_arabic` | Arabic-Indic and Persian digits <-> 0-9 |
|
|
34
|
+
| `normalize_punct` | ، ؛ ؟ -> , ; ? |
|
|
35
|
+
| `clean` | the usual combination in one call |
|
|
36
|
+
|
|
37
|
+
Normalization is lossy by design (good for matching, not for display). Keep the original text if you need to show it.
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
python -m pytest
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
MIT licensed.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: arabickit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Arabic text cleanup: tashkeel, letter variants, digits.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/arabickit
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/arabickit/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# arabickit
|
|
18
|
+
|
|
19
|
+
Small, dependency-free helpers to clean and normalize Arabic text before search, comparison, NLP or LLM prompts. Works as a library or a CLI.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from arabickit import clean, strip_tashkeel, digits_to_ascii
|
|
23
|
+
|
|
24
|
+
clean(" أَهْلاً بِكَ ١٢ ") # 'اهلا بك 12'
|
|
25
|
+
strip_tashkeel("بِسْمِ اللَّهِ") # 'بسم الله'
|
|
26
|
+
digits_to_ascii("٢٠٢٦") # '2026'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
echo "أَهْلاً بِكَ ١٢" | python arabickit.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
pip install arabickit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or copy `arabickit.py` into your project, it has no dependencies.
|
|
40
|
+
|
|
41
|
+
## Functions
|
|
42
|
+
|
|
43
|
+
| Function | What it does |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `strip_tashkeel` | remove harakat and Quranic marks |
|
|
46
|
+
| `strip_tatweel` | remove kashida (ـ) |
|
|
47
|
+
| `normalize_letters` | أ إ آ ٱ -> ا, ى -> ي |
|
|
48
|
+
| `normalize_ta_marbuta` | ة -> ه (optional, lossy) |
|
|
49
|
+
| `digits_to_ascii` / `digits_to_arabic` | Arabic-Indic and Persian digits <-> 0-9 |
|
|
50
|
+
| `normalize_punct` | ، ؛ ؟ -> , ; ? |
|
|
51
|
+
| `clean` | the usual combination in one call |
|
|
52
|
+
|
|
53
|
+
Normalization is lossy by design (good for matching, not for display). Keep the original text if you need to show it.
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python -m pytest
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
MIT licensed.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
arabickit
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Arabic text cleanup: tashkeel, letter variants, digits, tatweel."""
|
|
2
|
+
import re, sys, argparse
|
|
3
|
+
|
|
4
|
+
TASHKEEL = re.compile(r"[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]")
|
|
5
|
+
TATWEEL = "\u0640"
|
|
6
|
+
AR_DIGITS = "٠١٢٣٤٥٦٧٨٩"
|
|
7
|
+
FA_DIGITS = "۰۱۲۳۴۵۶۷۸۹"
|
|
8
|
+
|
|
9
|
+
def strip_tashkeel(s): return TASHKEEL.sub("", s)
|
|
10
|
+
def strip_tatweel(s): return s.replace(TATWEEL, "")
|
|
11
|
+
|
|
12
|
+
def normalize_letters(s):
|
|
13
|
+
"""Alef variants -> ا, ى -> ي, ة kept (use normalize_ta_marbuta to change)."""
|
|
14
|
+
for a in "أإآٱ":
|
|
15
|
+
s = s.replace(a, "ا")
|
|
16
|
+
return s.replace("ى", "ي")
|
|
17
|
+
|
|
18
|
+
def normalize_ta_marbuta(s): return s.replace("ة", "ه")
|
|
19
|
+
|
|
20
|
+
def digits_to_ascii(s):
|
|
21
|
+
table = {ord(c): str(i) for i, c in enumerate(AR_DIGITS)}
|
|
22
|
+
table.update({ord(c): str(i) for i, c in enumerate(FA_DIGITS)})
|
|
23
|
+
return s.translate(table)
|
|
24
|
+
|
|
25
|
+
def digits_to_arabic(s):
|
|
26
|
+
return s.translate({ord(str(i)): c for i, c in enumerate(AR_DIGITS)})
|
|
27
|
+
|
|
28
|
+
def normalize_punct(s):
|
|
29
|
+
return s.replace("،", ",").replace("؛", ";").replace("؟", "?")
|
|
30
|
+
|
|
31
|
+
def collapse_spaces(s): return re.sub(r"[ \t\u00a0\u200b\u200c\u200f\u200e]+", " ", s).strip()
|
|
32
|
+
|
|
33
|
+
def clean(s, ta_marbuta=False, ascii_digits=True):
|
|
34
|
+
s = strip_tashkeel(strip_tatweel(s))
|
|
35
|
+
s = normalize_letters(s)
|
|
36
|
+
if ta_marbuta: s = normalize_ta_marbuta(s)
|
|
37
|
+
if ascii_digits: s = digits_to_ascii(s)
|
|
38
|
+
return collapse_spaces(s)
|
|
39
|
+
|
|
40
|
+
def main(argv=None):
|
|
41
|
+
ap = argparse.ArgumentParser(prog="arabickit")
|
|
42
|
+
ap.add_argument("file", nargs="?")
|
|
43
|
+
ap.add_argument("--ta-marbuta", action="store_true", help="also turn ة into ه")
|
|
44
|
+
ap.add_argument("--keep-digits", action="store_true", help="do not convert Arabic-Indic digits")
|
|
45
|
+
a = ap.parse_args(argv)
|
|
46
|
+
try:
|
|
47
|
+
text = open(a.file, encoding="utf-8").read() if a.file else sys.stdin.read()
|
|
48
|
+
except (OSError, UnicodeDecodeError) as e:
|
|
49
|
+
print(f"error: cannot read input: {e}", file=sys.stderr)
|
|
50
|
+
return 1
|
|
51
|
+
print("\n".join(clean(l, a.ta_marbuta, not a.keep_digits) for l in text.splitlines()))
|
|
52
|
+
return 0
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
sys.exit(main())
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "arabickit"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Arabic text cleanup: tashkeel, letter variants, digits."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "episodely" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/episodely/arabickit"
|
|
21
|
+
Issues = "https://github.com/episodely/arabickit/issues"
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
arabickit = "arabickit:main"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
py-modules = ["arabickit"]
|