diff --git a/num2words/lang_KO.py b/num2words/lang_KO.py index 575c3e2e..4664533f 100644 --- a/num2words/lang_KO.py +++ b/num2words/lang_KO.py @@ -22,6 +22,7 @@ import re + class Num2Word_KO(Num2Word_Base): CURRENCY_FORMS = { 'KRW': ('원', None), @@ -79,7 +80,7 @@ def setup(self): "칠십": "일흔", "팔십": "여든", "구십": "아흔"} - + def merge(self, lpair, rpair): ltext, lnum = lpair rtext, rnum = rpair @@ -96,7 +97,8 @@ def to_ordinal(self, value): self.verify_ordinal(value) outwords = self.to_cardinal(value).split(" ") if value % 100 != 0: - re_mid_words = '|'.join('(?<={})'.format(re.escape(delim)) for delim in ['천', '백']) + re_mid_words = '|'.join('(?<={})'.format(re.escape(delim)) + for delim in ['천', '백']) lastwords = re.split(re_mid_words, outwords[-1]) if "십" in lastwords[-1]: ten_one = lastwords[-1].split("십") diff --git a/tests/test_ko.py b/tests/test_ko.py index 3e53f89f..357bf13e 100644 --- a/tests/test_ko.py +++ b/tests/test_ko.py @@ -83,12 +83,12 @@ def test_currency(self): def test_ordinal(self): cases = [(1, "한"), (101, "백한"), (2, "두"), (5, "다섯"), (1050, "천쉰"), - (10, "열"), (20, "스무"), (21, "스물한"), (100, "백"), (1000, "천"), - (10000, "만"), (100000, "십만"), (1000000, "백만"), (100001, "십만 한"), - (10000000, "천만"), (100000000, "일억"), (1000000000, "십억"), - (10000000000, "백억"), (100000000000, "천억"), - (1000000000000, "일조"), (10000000000000, "십조"), - (25, "스물다섯"), (137, "백서른일곱")] + (10, "열"), (20, "스무"), (21, "스물한"), (100, "백"), + (1000, "천"), (10000, "만"), (100000, "십만"), (1000000, "백만"), + (100001, "십만 한"),(10000000, "천만"), (100000000, "일억"), + (1000000000, "십억"),(10000000000, "백억"), + (100000000000, "천억"), (1000000000000, "일조"), + (10000000000000, "십조"), (25, "스물다섯"), (137, "백서른일곱")] for num, out in cases: self.assertEqual(n2k(num, to="ordinal"), out)