Skip to content

Commit

Permalink
Merge pull request #32 from hmlendea/arabic
Browse files Browse the repository at this point in the history
Improved the `Arabic` transliteration
  • Loading branch information
hmlendea authored May 24, 2023
2 parents c738abf + 3322954 commit 96c5fd9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public void SetUp()
[TestCase("روما", "Rūmā")]
[TestCase("عَسْقَلَان", "ʿAsqalān")]
[TestCase("فِلَسْطِينَ", "Filasṭīn")]
[TestCase("فهرج", "Fahraǧ")]
[TestCase("هرتسليا", "Hirtsiliyā")]
[TestCase("يوانينا", "Īānīnā")]
public void GivenATextInArabicScript_WhenTransliteratingIntoLatin_ThenTheCorrectTextIsReturned(
string arabicText,
string expectedTransliteratedText)
Expand Down
2 changes: 2 additions & 0 deletions TransliterationAPI/Service/TransliterationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ async Task<string> GetTransliteratedText(string text, string language)
case "ady": // Adyghe
return await translitterationDotComTransliterator.Transliterate(text, "ady", "iso-9");
case "ar": // Arabic
case "ary": // Maghrebi Arabic
case "arz": // Egyptian Arabic
return arabicTransliterator.Transliterate(text);
case "ba": // Bashkir
return await translitterationDotComTransliterator.Transliterate(text, "bak", "iso-9");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ string ApplyFixes(string text)
fixedText = fixedText.Replace("-r", "-R");

fixedText = Regex.Replace(fixedText, "([Ǧǧ])b", "$1ib");
fixedText = Regex.Replace(fixedText, "([Īī])wā", "$1ā");
fixedText = Regex.Replace(fixedText, "([Nn])m", "$1im");
fixedText = Regex.Replace(fixedText, "([Qq])f", "$1if");
fixedText = Regex.Replace(fixedText, "", "Ba");
fixedText = Regex.Replace(fixedText, "Dm", "Dim");
fixedText = Regex.Replace(fixedText, "Fh", "Fah");
fixedText = Regex.Replace(fixedText, "Hr", "Hir");
fixedText = Regex.Replace(fixedText, "Is", "ʾIs");
fixedText = Regex.Replace(fixedText, "R([hm])", "Ra$1");
Expand All @@ -170,7 +172,7 @@ string ApplyFixes(string text)
fixedText = Regex.Replace(fixedText, "lnd", "land");
fixedText = Regex.Replace(fixedText, "lẗ", "laḧ");
fixedText = Regex.Replace(fixedText, "", "maš");
fixedText = Regex.Replace(fixedText, "rzn", "rzin");
fixedText = Regex.Replace(fixedText, "", "raǧ");
fixedText = Regex.Replace(fixedText, "tsl", "tsil");

fixedText = Regex.Replace(fixedText, "rzn", "rzin");
Expand Down

0 comments on commit 96c5fd9

Please sign in to comment.