Skip to content

Commit

Permalink
increase of coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiBY committed Aug 18, 2023
1 parent 585778f commit d1229aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 10 additions & 6 deletions num2words/lang_BY.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ def to_ordinal(self, number, gender="m"):
if lastword[-1] == "ч":
lastword = lastword + "ны"

if "дву" in lastword[-2]:
lastword[-2].replace("дву", "дзву")

elif lastword[-1] == "н" or lastword[-2] == "н":
lastword = lastword[: lastword.rfind("н") + 1] + "ны"
Expand All @@ -257,8 +255,8 @@ def to_ordinal(self, number, gender="m"):
lastword = lastword[:-1] + "ая"

if gender == "n":
if lastword[-2:] == [
"ці",
if lastword[-2:] in [
"ці", "ца"
]:
lastword = lastword[:-2] + "цяе"
else:
Expand All @@ -269,10 +267,16 @@ def to_ordinal(self, number, gender="m"):
outwords[-2] = outwords[-1]
del outwords[-1]

if len(outwords) > 1 and "тысяч" in outwords[-1]:
outwords[-2] = outwords[-2] + outwords[-1]
if len(outwords) > 2 and "тысяч" in outwords[-1]:
if 'сорак' in outwords[-3]:
outwords[-3] = outwords[-3].replace('сорак', 'сарака')
outwords[-3] = outwords[-3] + outwords[-2] + outwords[-1]
del outwords[-1]
del outwords[-1]

elif len(outwords) > 1 and "тысяч" in outwords[-1]:
outwords[-2] = outwords[-2] + outwords[-1]
del outwords[-1]
return " ".join(outwords).strip()

def _money_verbose(self, number, currency):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_by.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def test_floating_point(self):
def test_to_ordinal(self):
self.assertEqual(num2words(1, lang="by", to="ordinal"), "першы")
self.assertEqual(num2words(5, lang="by", to="ordinal"), "пяты")
self.assertEqual(num2words(6, lang="by", to="ordinal"), "шосты")
self.assertEqual(num2words(10, lang="by", to="ordinal"), "дзясяты")

self.assertEqual(num2words(13, lang="by", to="ordinal"), "трынаццаты")
Expand All @@ -106,6 +107,10 @@ def test_to_ordinal(self):
num2words(23, lang="by", to="ordinal", gender="f"),
"дваццаць трэцяя",
)
self.assertEqual(
num2words(23, lang="by", to="ordinal", gender="n"),
"дваццаць трэцяе",
)
self.assertEqual(num2words(40, lang="by", to="ordinal"), "саракавы")
self.assertEqual(
num2words(61, lang="by", to="ordinal"), "шэсцьдзясят першы"
Expand Down Expand Up @@ -144,6 +149,9 @@ def test_to_ordinal(self):
self.assertEqual(
num2words(10000, lang="by", to="ordinal"), "дзесяцітысячны"
)
self.assertEqual(
num2words(42000, lang="by", to="ordinal"), "саракадвухтысячны"
)
self.assertEqual(
num2words(1000000, lang="by", to="ordinal"), "мільённы"
)
Expand Down

0 comments on commit d1229aa

Please sign in to comment.