Skip to content

Commit

Permalink
adding a random vowel when needed was replaced with adding "a" for th…
Browse files Browse the repository at this point in the history
…e transitions to be unique.
  • Loading branch information
rexa222 committed Apr 22, 2023
1 parent c7a8257 commit bbaba99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions arabic2latin/arabic2latin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import random

MAPPING = {
'أ': 'a', 'إ': 'e', 'ا': 'a', 'آ': 'aa', 'ب': 'b', 'پ': 'p', 'ت': 't', 'ث': 'th',
'ج': 'j', 'ح': 'h', 'خ': 'kh', 'د': 'd', 'ذ': 'th', 'ر': 'r', 'ز': 'z',
Expand Down Expand Up @@ -57,7 +55,7 @@ def arabic_to_latin(text, debug=False):
elif text[c-1] in "اىيی" or text[c+1] in "اىيی":
if result[-1] not in VOWELS and result[-3:] not in " al" and MAPPING[char] != "y":
if not no_vowel:
result += random.choices(("e", "a"), weights=(1, 4))[0]
result += "a"
else:
no_vowel = False

Expand All @@ -72,7 +70,7 @@ def arabic_to_latin(text, debug=False):
else:
if result[-1] not in VOWELS and MAPPING[char][:1] not in VOWELS and result[-3:] not in " al" and MAPPING[char] != "y":
if not no_vowel:
result += random.choices(("e", "a"), weights=(1, 4))[0]
result += "a"
else:
no_vowel = False

Expand Down
2 changes: 1 addition & 1 deletion arabic2latin/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.0"
__version__ = "1.1.1"

0 comments on commit bbaba99

Please sign in to comment.