|
|
|
|
@ -1154,4 +1154,30 @@ class Utils {
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Normalize Arabic text for search by handling Hamza variations and removing diacritics
|
|
|
|
|
/// This makes searching more flexible for Arabic text
|
|
|
|
|
static String normalizeArabicText(String text) {
|
|
|
|
|
if (text.isEmpty) return text;
|
|
|
|
|
|
|
|
|
|
String normalized = text;
|
|
|
|
|
|
|
|
|
|
// Normalize Hamza variations to a single character 'ا'
|
|
|
|
|
normalized = normalized.replaceAll('أ', 'ا'); // Hamza on Alif
|
|
|
|
|
normalized = normalized.replaceAll('إ', 'ا'); // Hamza below Alif
|
|
|
|
|
normalized = normalized.replaceAll('آ', 'ا'); // Madda on Alif
|
|
|
|
|
normalized = normalized.replaceAll('ء', 'ا'); // Hamza alone
|
|
|
|
|
normalized = normalized.replaceAll('ؤ', 'و'); // Hamza on Waw
|
|
|
|
|
normalized = normalized.replaceAll('ئ', 'ي'); // Hamza on Ya
|
|
|
|
|
|
|
|
|
|
// Normalize Alif Maqsura to Ya
|
|
|
|
|
normalized = normalized.replaceAll('ى', 'ي');
|
|
|
|
|
|
|
|
|
|
// Remove Arabic diacritics (Tashkeel)
|
|
|
|
|
normalized = normalized.replaceAll(RegExp(r'[\u064B-\u065F]'), ''); // Fatha, Damma, Kasra, etc.
|
|
|
|
|
normalized = normalized.replaceAll(RegExp(r'[\u0670]'), ''); // Superscript Alif
|
|
|
|
|
normalized = normalized.replaceAll(RegExp(r'[\u0640]'), ''); // Tatweel
|
|
|
|
|
|
|
|
|
|
return normalized;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|