Skip to content

Commit

Permalink
Edit pass flake8 requirements for PR savoirfairelinux#555, Fix error …
Browse files Browse the repository at this point in the history
…Korean ordinal conversion
  • Loading branch information
dogzz9445 committed Feb 3, 2024
1 parent 5670f76 commit 0ac94f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions num2words/lang_KO.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import re


class Num2Word_KO(Num2Word_Base):
CURRENCY_FORMS = {
'KRW': ('원', None),
Expand Down Expand Up @@ -79,7 +80,7 @@ def setup(self):
"칠십": "일흔",
"팔십": "여든",
"구십": "아흔"}

def merge(self, lpair, rpair):
ltext, lnum = lpair
rtext, rnum = rpair
Expand All @@ -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("십")
Expand Down
12 changes: 6 additions & 6 deletions tests/test_ko.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 0ac94f0

Please sign in to comment.