Skip to content

Commit

Permalink
Merge pull request #80 from hmlendea/arabic
Browse files Browse the repository at this point in the history
Improved transliteration for `Arabic`
  • Loading branch information
hmlendea authored Dec 13, 2023
2 parents 9d9b0a9 + 2b05652 commit fb5b5a0
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions TransliterationAPI/Service/Transliterators/ArabicTransliterator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,31 @@ string ApplyFixes(string text)
fixedText = Regex.Replace(fixedText, @"([ -])ǧ", "$1Ǧ");
fixedText = Regex.Replace(fixedText, @"([ -])ẖ", "$1H̱");

// *a*
fixedText = Regex.Replace(fixedText, @"([Bb])([nr])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([Bb])([t])", "$1i$2");
fixedText = Regex.Replace(fixedText, @"([Bb])ū", "$1aū");
fixedText = Regex.Replace(fixedText, @"([Bb])ʾir", "$1iʾr");
fixedText = Regex.Replace(fixedText, @"([Ff])r", "$1ur");
fixedText = Regex.Replace(fixedText, @"([ǦJǧj])m", "$1um");
fixedText = Regex.Replace(fixedText, @"([BKMQbkmq])([sṣš])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([FLMTṬflmtṭ])([ln])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([HḤhḥ])([blmrsṣštṭ])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([KQkq])s", "$1as");
fixedText = Regex.Replace(fixedText, @"([Kk])w", "$1uw");
fixedText = Regex.Replace(fixedText, @"([LMlm])([ln])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([Mm])([sṣ])", "$1i$2");
fixedText = Regex.Replace(fixedText, @"([Mm])q", "$1uq");
fixedText = Regex.Replace(fixedText, @"([Rr])w", "$1ū");
fixedText = Regex.Replace(fixedText, @"([Qq])([h])", "$1a$2");
fixedText = Regex.Replace(fixedText, @"([Ss])b", "$1ab");
fixedText = Regex.Replace(fixedText, @"\b([N])([ǧ])", "$1a$2");
// *i*
fixedText = Regex.Replace(fixedText, @"([BTbt])([lt])", "$1i$2");
fixedText = Regex.Replace(fixedText, @"([Mm])([rsṣ])", "$1i$2");
fixedText = Regex.Replace(fixedText, @"([Šš])n", "$1in");
fixedText = Regex.Replace(fixedText, @"([Ṭṭ])l", "$1al");
// *u*
fixedText = Regex.Replace(fixedText, @"([Dd])([ǧn])", "$1u$2");
fixedText = Regex.Replace(fixedText, @"([Mm])([q])", "$1u$2");
fixedText = Regex.Replace(fixedText, @"([FZfz])([rq])", "$1u$2");
fixedText = Regex.Replace(fixedText, @"([ǦJǧj])m", "$1um");
fixedText = Regex.Replace(fixedText, @"([Kk])w", "$1uw");

fixedText = Regex.Replace(fixedText, @"([Bb])ʾir", "$1iʾr");
fixedText = Regex.Replace(fixedText, @"([Rr])w", "$1ū");
fixedText = Regex.Replace(fixedText, @"āhٌ", "ah");
fixedText = Regex.Replace(fixedText, @"āšr\b", "āšir ");
fixedText = Regex.Replace(fixedText, @"āūm", "āwam");
fixedText = Regex.Replace(fixedText, @"bl", "bil");
fixedText = Regex.Replace(fixedText, @"dn", "dun");
fixedText = Regex.Replace(fixedText, @"dwd", "dūd");
fixedText = Regex.Replace(fixedText, @"īā", "iyā");
fixedText = Regex.Replace(fixedText, @"īah\b", "iyyah");
Expand All @@ -232,12 +236,9 @@ string ApplyFixes(string text)
fixedText = Regex.Replace(fixedText, @"l--[Ll]", "ll");
fixedText = Regex.Replace(fixedText, @"lyā", "liyā");
fixedText = Regex.Replace(fixedText, @"lyl", "līl");
fixedText = Regex.Replace(fixedText, @"mr", "mir");
fixedText = Regex.Replace(fixedText, @"mš", "maš");
fixedText = Regex.Replace(fixedText, @"r([kǧ])", "ra$1");
fixedText = Regex.Replace(fixedText, @"shׂr", "sr");
fixedText = Regex.Replace(fixedText, @"sn", "san");
fixedText = Regex.Replace(fixedText, @"tl", "til");
fixedText = Regex.Replace(fixedText, @"tsl", "tsil");
fixedText = Regex.Replace(fixedText, @"un\b", "unn");
fixedText = Regex.Replace(fixedText, @"w([my])", "wa$1");
Expand Down

0 comments on commit fb5b5a0

Please sign in to comment.