mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
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:
@@ -143,7 +143,7 @@ class Num2Word_CZ(Num2Word_Base):
|
|||||||
elif n1 > 0 and not (i > 0 and x == 1):
|
elif n1 > 0 and not (i > 0 and x == 1):
|
||||||
words.append(ONES[n1][0])
|
words.append(ONES[n1][0])
|
||||||
|
|
||||||
if i > 0:
|
if x > 0 and i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ def int2word(n):
|
|||||||
elif n1 > 0 and not (i > 0 and x == 1):
|
elif n1 > 0 and not (i > 0 and x == 1):
|
||||||
words.append(ONES[n1][0])
|
words.append(ONES[n1][0])
|
||||||
|
|
||||||
if i > 0:
|
if x > 0 and i > 0:
|
||||||
if i <= 2:
|
if i <= 2:
|
||||||
words.append(THOUSANDS[i][0])
|
words.append(THOUSANDS[i][0])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class Num2Word_LT(Num2Word_Base):
|
|||||||
else:
|
else:
|
||||||
words.append(ONES[n1][0])
|
words.append(ONES[n1][0])
|
||||||
|
|
||||||
if i > 0:
|
if x > 0 and i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class Num2Word_LV(Num2Word_Base):
|
|||||||
elif n1 > 0 and not (i > 0 and x == 1):
|
elif n1 > 0 and not (i > 0 and x == 1):
|
||||||
words.append(ONES[n1][0])
|
words.append(ONES[n1][0])
|
||||||
|
|
||||||
if i > 0 and x != 0:
|
if x > 0 and i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class Num2Word_PL(Num2Word_Base):
|
|||||||
elif n1 > 0 and not (i > 0 and x == 1):
|
elif n1 > 0 and not (i > 0 and x == 1):
|
||||||
words.append(ONES[n1][0])
|
words.append(ONES[n1][0])
|
||||||
|
|
||||||
if i > 0:
|
if x > 0 and i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ class Num2Word_RU(Num2Word_Base):
|
|||||||
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
|
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
|
||||||
words.append(ones[n1][0])
|
words.append(ones[n1][0])
|
||||||
|
|
||||||
if i > 0 and x != 0:
|
if x > 0 and i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ class Num2Word_UK(Num2Word_Base):
|
|||||||
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
|
ones = ONES_FEMININE if i == 1 or feminine and i == 0 else ONES
|
||||||
words.append(ones[n1][0])
|
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]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ class Num2WordsPLTest(TestCase):
|
|||||||
"miliard dwieście trzydzieści cztery miliony pięćset "
|
"miliard dwieście trzydzieści cztery miliony pięćset "
|
||||||
"sześćdziesiąt siedem tysięcy osiemset dziewięćdzisiąt"
|
"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(
|
self.assertEqual(
|
||||||
num2words(215461407892039002157189883901676, lang='pl'),
|
num2words(215461407892039002157189883901676, lang='pl'),
|
||||||
"dwieście piętnaście kwintylionów czterysta sześćdziesiąt jeden "
|
"dwieście piętnaście kwintylionów czterysta sześćdziesiąt jeden "
|
||||||
|
|||||||
Reference in New Issue
Block a user