Skip to content

Commit

Permalink
Fix error about Korean ordinal conversion, only errors on issue savoi…
Browse files Browse the repository at this point in the history
  • Loading branch information
dogzz9445 committed Jan 5, 2024
1 parent 974f7a8 commit 17e2c85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion num2words/lang_KO.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def to_ordinal(self, value):
self.verify_ordinal(value)
if value == 1:
return "첫 번째"
if value == 100:
return "백 번째"
outwords = self.to_cardinal(value).split(" ")
lastwords = outwords[-1].split("백")
if "십" in lastwords[-1]:
Expand All @@ -107,7 +109,8 @@ def to_ordinal(self, value):
pass
lastwords[-1] = ''.join(ten_one)
else:
lastwords[-1] = self.ords[lastwords[-1]]
if lastwords[-1] in self.ords:
lastwords[-1] = self.ords[lastwords[-1]]
outwords[-1] = "백 ".join(lastwords)
return " ".join(outwords) + " 번째"

Expand Down
3 changes: 2 additions & 1 deletion tests/test_ko.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def test_currency(self):

def test_ordinal(self):
cases = [(1, "첫 번째"), (101, "백 한 번째"), (2, "두 번째"), (5, "다섯 번째"),
(10, "열 번째"), (25, "스물다섯 번째"), (137, "백 서른일곱 번째")]
(10, "열 번째"), (100, "백 번째"), (1000, "천 번째"), (10000, "만 번째"),
(25, "스물다섯 번째"), (137, "백 서른일곱 번째")]
for num, out in cases:
self.assertEqual(n2k(num, to="ordinal"), out)

Expand Down

0 comments on commit 17e2c85

Please sign in to comment.