diff --git a/num2words/lang_KO.py b/num2words/lang_KO.py index 65f4531e..b59aceda 100644 --- a/num2words/lang_KO.py +++ b/num2words/lang_KO.py @@ -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]: @@ -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) + " 번째" diff --git a/tests/test_ko.py b/tests/test_ko.py index c98ad881..085d0c09 100644 --- a/tests/test_ko.py +++ b/tests/test_ko.py @@ -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)