Skip to content

Commit

Permalink
fix: keep punctuations, found from payyans-go test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
asdofindia committed Feb 17, 2024
1 parent 53ef775 commit a4653fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libindic/payyans/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def ASCII2Unicode(self, ascii_text, font):
unicode_text = transposed_text.translate(translator)

# മൂന്നാമത്തെ ഓട്ടം: ചേരുംപടി ചേര്‍ക്കുക
unicode_text = self.normalizer.normalize(unicode_text)
unicode_text = self.normalizer.normalize(unicode_text, keep_punctuations=True)

return unicode_text # മതം മാറ്റി തിരിച്ചു കൊടുക്ക്വാ !

Expand Down
28 changes: 22 additions & 6 deletions libindic/payyans/tests/test_payyans.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,32 @@ def setUp(self):
self.payyans = Payyans()

def test_ascii2unicode(self):
self.assertEqual(
self.payyans.ASCII2Unicode(
"aebmfw", "ML-TTAmbili"), u"മലയാളം")
self.assertEqual(self.payyans.ASCII2Unicode("aebmfw", "ML-TTAmbili"), "മലയാളം")

def test_unicode2ascii(self):
self.assertEqual(self.payyans.Unicode2ASCII("മലയാളം", "ML-TTAmbili"), "aebmfw")

def test_double_swaras(self):
inputs = ["ss{U", "t{]aw", "kvss{XWX", "{ZpXKXnbnÂ"]
expected = ["ഡ്രൈ", "പ്രേമം", "സ്ത്രൈണത", "ദ്രുതഗതിയില്‍"]
inputs = [
",",
"ss{U",
"t{]aw",
"kvss{XWX",
"{ZpXKXnbnÂ",
r"\nt¡mf sSkv‌e",
r"{][m\ambpw C´y³ kwØm\§fmb lnamN {]tZiv, P½p ImivaoÀ F¶nhnS§fn Xmakn¡p¶ Hcp AÀ²þCt´mþBcy³ hwiobþ`mjm]camb tKm{XamWv KÍn",
r"Hcp hÀj¯n s^{_phcn amk¯n\p 29 Znhkw Ds­¦n B hÀjs¯ A[nhÀjw F¶p ]dbp¶p. Hcp hÀjw A[nhÀjamtWm F¶v IW¡m¡p¶ AÂsKmcnXamWv Nn{X¯nÂ.",
]
expected = [
",",
"ഡ്രൈ",
"പ്രേമം",
"സ്ത്രൈണത",
"ദ്രുതഗതിയില്‍",
"നിക്കോള ടെസ്‌ല",
"പ്രധാനമായും ഇന്ത്യന്‍ സംസ്ഥാനങ്ങളായ ഹിമാചല്‍ പ്രദേശ്, ജമ്മു കാശ്മീര്‍ എന്നിവിടങ്ങളില്‍ താമസിക്കുന്ന ഒരു അര്‍ദ്ധ-ഇന്തോ-ആര്യന്‍ വംശീയ-ഭാഷാപരമായ ഗോത്രമാണ് ഗഡ്ഡി",
"ഒരു വര്‍ഷത്തില്‍ ഫെബ്രുവരി മാസത്തിനു 29 ദിവസം ഉണ്ടെങ്കില്‍ ആ വര്‍ഷത്തെ അധിവര്‍ഷം എന്നു പറയുന്നു. ഒരു വര്‍ഷം അധിവര്‍ഷമാണോ എന്ന് കണക്കാക്കുന്ന അല്‍ഗൊരിതമാണ് ചിത്രത്തില്‍.",
]
for i in range(len(inputs)):
actual = self.payyans.ASCII2Unicode(inputs[i], "ML-TTKarthika")
self.assertEqual(actual, expected[i])

0 comments on commit a4653fb

Please sign in to comment.