fix missing words

This commit is contained in:
Dhaifallah Alwadani
2017-06-22 23:48:44 +03:00
parent eea901734a
commit 6c3e75d4c8

View File

@@ -25,27 +25,28 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
self.cards[10**n] = word + "illion" self.cards[10**n] = word + "illion"
def setup(self): def setup(self):
self.negword = "minus " self.negword = "سالب "
self.pointword = "point" self.pointword = "فاصلة"
self.errmsg_nornum = "Only numbers may be converted to words." self.errmsg_nornum = "Only numbers may be converted to words."
self.exclude_title = ["and", "point", "minus"] self.exclude_title = ["و", "فاصلة", "سالب"]
self.mid_numwords = [(1000000, "مليون"),(1000, "ألف"), (100, "مئة"), self.mid_numwords = [(1000000, "مليون"),(1000, "ألف"), (100, "مئة"),
(90, "تسعين"), (80, "ثمانين"), (70, "سبعين"), (90, "تسعين"), (80, "ثمانين"), (70, "سبعين"),
(60, "ستين"), (50, "خمسين"), (40, "أربعين"), (60, "ستين"), (50, "خمسين"), (40, "أربعين"),
(30, "ثلاثين")] (30, "ثلاثين")]
self.low_numwords = ["عشرين", "تسعة عشر", "ثمانية عشر", "سبعة عشر", self.low_numwords = ["عشرين", "تسعة عشر", "ثمانية عشر", "سبعة عشر",
"sixteen", "خمسة عشر", "fourteen", "thirteen", "ستة عشر", "خمسة عشر", "أربعة عشر", "ثلاثة عشر",
"twelve", "أحد عشر", "ten", "nine", "ثمانية", "اثناعشر", "أحد عشر", "عشرة", "تسعة", "ثمانية",
"seven", "six", "خمسة", "أربعة", "three", "اثنين", "سبعة", "ستة", "خمسة", "أربعة", "ثلاثة", "اثنين",
"واحد", "صفر"] "واحد", "صفر"]
self.ords = { "one" : "first", self.ords = { "واحد" : "أول",
"two" : "second", "اثنين" : "ثاني",
"three" : "third", "ثلاثة" : "ثالث",
"five" : "fifth", "أربعة": "رابع",
"eight" : "eighth", "خمسة" : "خامس",
"nine" : "ninth", "ثمانية" : "ثامن",
"twelve" : "twelfth" } "تسعة" : "تاسع",
"اثناعشر" : "ثاني عشر" }
def merge(self, lpair, rpair): def merge(self, lpair, rpair):
@@ -58,7 +59,7 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
elif lnum >= 100 > rnum: elif lnum >= 100 > rnum:
return ("%s و %s"%(ltext, rtext), lnum + rnum) return ("%s و %s"%(ltext, rtext), lnum + rnum)
elif rnum > lnum: elif rnum > lnum:
if lnum == 1 and rnum in [100, 1000]: if lnum == 1 and rnum in [100, 1000, 1000000]:
return ("%s"%(rtext), rnum * lnum) return ("%s"%(rtext), rnum * lnum)
if lnum == 2 and rnum == 100: if lnum == 2 and rnum == 100:
return ("مئتين", rnum * lnum) return ("مئتين", rnum * lnum)
@@ -76,9 +77,7 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
try: try:
lastword = self.ords[lastword] lastword = self.ords[lastword]
except KeyError: except KeyError:
if lastword[-1] == "y": lastword += ""
lastword = lastword[:-1] + "ie"
lastword += "th"
lastwords[-1] = self.title(lastword) lastwords[-1] = self.title(lastword)
outwords[-1] = "،".join(lastwords) outwords[-1] = "،".join(lastwords)
return " ".join(outwords) return " ".join(outwords)