Overview
The normalization module exports two primary functions:removeTashkeel()- Removes diacritics and Quranic marksnormalizeArabic()- Advanced normalization for search indexing
Remove diacritics
removeTashkeel(text: string): string
Removes Tashkeel (diacritics) and Quranic marks from Arabic text.
Use case: Stripping diacritics for display or simple comparisons.
What it removes
Fromsrc/utils/normalization.ts:7-11:
- Wasl alef (converts to regular alef)
- All diacritical marks (Unicode range
\u064B-\u065F) - Quranic annotation marks
- Superscript alef
Advanced normalization
normalizeArabic(text: string): string
Advanced Arabic normalization for search indexing. Handles Unicode normalization, variant unification, and cleanup.
Use case: Preparing user input for searching (unifies alef variants, removes tashkeel, etc).
Normalization steps
1
Remove diacritics
Calls
removeTashkeel() to strip all diacritical marks and applies Unicode NFC normalization.2
Remove special characters
Removes dagger alif and tatweel (elongation character).
3
Unify alef variants
Normalizes all alef variants to a single form.Converts: إ أ آ ٱ → ا
4
Unify hamza variants
Normalizes hamza on different carriers to standalone hamza.Converts: ؤ ئ → ء
5
Unify ya variants
Converts alif maqsura to regular ya.Converts: ى → ي
6
Clean whitespace and control characters
Removes line breaks, non-Arabic characters, and normalizes whitespace.
7
Trim and return
Removes leading and trailing whitespace.
Full implementation
Fromsrc/utils/normalization.ts:20-43:
Usage in search
ThenormalizeArabic() function is used internally throughout the search engine to ensure consistent matching:
Character unification table
Empty input strings return empty strings - the function gracefully handles null or undefined input.