Arabic text normalization — tashkeel, alef, hamza, search keys, sorting
Project description
devsamhan-arabic-text (Python)
مكتبة Python لتطبيع النص العربي — تشكيل، ألفات، همزات، بحث، فرز.
بدون تبعيات خارجية. متوافقة مع مواصفات devsamhan-arabic v1.0.0.
التثبيت
pip install devsamhan-arabic-text
أو محلياً:
pip install -e .
الاستخدام السريع
from devsamhan_arabic_text import (
to_search_key, to_loose_search_key, to_display_key,
to_slug, normalize_name, sort_arabic, compare_arabic,
remove_tashkeel, normalize_alef, normalize_digits,
is_arabic, arabic_ratio,
)
# مفتاح بحث للتخزين في قاعدة البيانات
to_search_key('مُحَمَّدٌ') # → 'محمد'
to_search_key('فاطمة العلي') # → 'فاطمة العلي'
# مفتاح متساهل للاستعلام (يطابق فاطمة وفاطمه)
to_loose_search_key('فاطمة') # → 'فاطمه'
# slug لـ URL
to_slug('مدينة الرياض') # → 'مدينه-الرياض'
# ترتيب قائمة
sort_arabic(['يوسف', 'أحمد', 'محمد']) # → ['أحمد', 'محمد', 'يوسف']
# تحويل الأرقام
normalize_digits('١٢٣', 'western') # → '123'
normalize_digits('123', 'eastern') # → '١٢٣'
الـ API
| الدالة | الوصف |
|---|---|
to_search_key(text) |
مفتاح بحث للتخزين. يحافظ على ة. |
to_loose_search_key(text) |
مثل to_search_key + ة→ه. للاستعلام فقط. |
to_display_key(text) |
يُزيل التطويل فقط. يحافظ على التشكيل. |
to_slug(text) |
معرّف URL عربي آمن. |
normalize_name(text) |
تطبيع الأسماء. يحافظ على ى و ة. |
to_sort_key(text) |
مفتاح فرز. |
sort_arabic(list) |
ترتيب مستقر بـ to_sort_key. |
compare_arabic(a, b) |
مقارنة — يُعيد -1 أو 0 أو 1. |
remove_tashkeel(text) |
حذف جميع علامات الشكل. |
remove_tatweel(text) |
حذف التطويل U+0640. |
normalize_alef(text) |
أ إ آ ٱ → ا |
normalize_hamza(text) |
ؤ ئ → ء |
normalize_ya(text) |
ى ی → ي |
normalize_ta_marbouta(text) |
ة → ه. يجب استدعاؤها صراحةً. |
normalize_presentation_forms(text) |
أشكال العرض FB50–FEFF → يونيكود قياسي. |
normalize_digits(text, to) |
تحويل الأرقام: 'western' أو 'eastern'. |
is_arabic(text) |
True إذا كان النص يحتوي على أي حرف عربي. |
arabic_ratio(text) |
نسبة الأحرف العربية (0.0–1.0). |
SPEC_VERSION |
'1.0.0' |
الترخيص
MIT — Devsamhan
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file devsamhan_arabic_text-1.0.0.tar.gz.
File metadata
- Download URL: devsamhan_arabic_text-1.0.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6fa1d5d4f4a5119a69147e3f0a6e73d9e84324ea4ddf99359bb83dec0c4844b5
|
|
| MD5 |
e907a565f48f2fa4c6f205bcab26829b
|
|
| BLAKE2b-256 |
56e3ef2866c729be90b080819b03a5aec531b28b5fbcead39575acfc8525a380
|
File details
Details for the file devsamhan_arabic_text-1.0.0-py3-none-any.whl.
File metadata
- Download URL: devsamhan_arabic_text-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a829f1bae1d66a6c30f3e6914844a531b08bb67bb6b78a38f2b2dd84deb3e3bb
|
|
| MD5 |
924e47808a2472118aa8fc156018b1fa
|
|
| BLAKE2b-256 |
887dd1ba60a1072ed38c97c47fda097886342c69f1d44d45383c8f70aeef40b8
|