Function signature
Parameters
string
required
The input Arabic text to normalize
Returns
string
The normalized string with all transformations applied
What transformations are applied
The function applies the following transformations in order:- Removes tashkeel (diacritics) - Strips all diacritical marks and Quranic symbols
- Unicode normalization - Applies NFC (Canonical Decomposition followed by Canonical Composition)
- Removes dagger alif and tatweel - Removes U+0670 (dagger alif) and U+0640 (tatweel/kashida)
- Unifies alef variants - Converts إ أ آ ٱ → ا (regular alef)
- Unifies hamza variants - Converts ؤ ئ ء → ء (standalone hamza)
- Unifies alif maqsura - Converts ى → ي (yaa)
- Removes control characters - Strips CRLF and non-Arabic symbols
- Normalizes whitespace - Replaces multiple spaces with single space
- Trims whitespace - Removes leading and trailing whitespace