no word for zero value of thousand's power; PL unit test fix

Before: 1_000_000_000 = "miliard milionów tysięcy" (with words for zero millions and thousands)
After: "miliard" (no words if value for given power of 1000 is 0)
This commit is contained in:
Marek Madejski
2018-12-03 12:03:16 +01:00
parent 518ce0b606
commit b8cd4ba181
8 changed files with 11 additions and 7 deletions

View File

@@ -143,7 +143,7 @@ class Num2Word_CZ(Num2Word_Base):
elif n1 > 0 and not (i > 0 and x == 1):
words.append(ONES[n1][0])
if i > 0:
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -113,7 +113,7 @@ def int2word(n):
elif n1 > 0 and not (i > 0 and x == 1):
words.append(ONES[n1][0])
if i > 0:
if x > 0 and i > 0:
if i <= 2:
words.append(THOUSANDS[i][0])
else:

View File

@@ -169,7 +169,7 @@ class Num2Word_LT(Num2Word_Base):
else:
words.append(ONES[n1][0])
if i > 0:
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -176,7 +176,7 @@ class Num2Word_LV(Num2Word_Base):
elif n1 > 0 and not (i > 0 and x == 1):
words.append(ONES[n1][0])
if i > 0 and x != 0:
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -154,7 +154,7 @@ class Num2Word_PL(Num2Word_Base):
elif n1 > 0 and not (i > 0 and x == 1):
words.append(ONES[n1][0])
if i > 0:
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -223,7 +223,7 @@ class Num2Word_RU(Num2Word_Base):
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
words.append(ones[n1][0])
if i > 0 and x != 0:
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -162,7 +162,7 @@ class Num2Word_UK(Num2Word_Base):
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
words.append(ones[n1][0])
if i > 0 and ((n1 + n2 + n3) > 0):
if x > 0 and i > 0:
words.append(self.pluralize(x, THOUSANDS[i]))
return ' '.join(words)

View File

@@ -45,6 +45,10 @@ class Num2WordsPLTest(TestCase):
"miliard dwieście trzydzieści cztery miliony pięćset "
"sześćdziesiąt siedem tysięcy osiemset dziewięćdzisiąt"
)
self.assertEqual(
num2words(10000000001000000100000, lang='pl'),
"dziesięć tryliardów bilion sto tysięcy"
)
self.assertEqual(
num2words(215461407892039002157189883901676, lang='pl'),
"dwieście piętnaście kwintylionów czterysta sześćdziesiąt jeden "