mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Many PEP8 fixes
Signed-off-by: William Moreno Reyes <williamjmorenor@gmail.com>
This commit is contained in:
@@ -70,6 +70,7 @@ CONVERTER_CLASSES = {
|
|||||||
'uk': lang_UK.Num2Word_UK()
|
'uk': lang_UK.Num2Word_UK()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def num2words(number, ordinal=False, lang='en'):
|
def num2words(number, ordinal=False, lang='en'):
|
||||||
# We try the full language first
|
# We try the full language first
|
||||||
if lang not in CONVERTER_CLASSES:
|
if lang not in CONVERTER_CLASSES:
|
||||||
|
|||||||
@@ -41,29 +41,24 @@ class Num2Word_Base(object):
|
|||||||
|
|
||||||
self.MAXVAL = 1000 * self.cards.order[0]
|
self.MAXVAL = 1000 * self.cards.order[0]
|
||||||
|
|
||||||
|
|
||||||
def set_numwords(self):
|
def set_numwords(self):
|
||||||
self.set_high_numwords(self.high_numwords)
|
self.set_high_numwords(self.high_numwords)
|
||||||
self.set_mid_numwords(self.mid_numwords)
|
self.set_mid_numwords(self.mid_numwords)
|
||||||
self.set_low_numwords(self.low_numwords)
|
self.set_low_numwords(self.low_numwords)
|
||||||
|
|
||||||
|
|
||||||
def gen_high_numwords(self, units, tens, lows):
|
def gen_high_numwords(self, units, tens, lows):
|
||||||
out = [u + t for t in tens for u in units]
|
out = [u + t for t in tens for u in units]
|
||||||
out.reverse()
|
out.reverse()
|
||||||
return out + lows
|
return out + lows
|
||||||
|
|
||||||
|
|
||||||
def set_mid_numwords(self, mid):
|
def set_mid_numwords(self, mid):
|
||||||
for key, val in mid:
|
for key, val in mid:
|
||||||
self.cards[key] = val
|
self.cards[key] = val
|
||||||
|
|
||||||
|
|
||||||
def set_low_numwords(self, numwords):
|
def set_low_numwords(self, numwords):
|
||||||
for word, n in zip(numwords, range(len(numwords) - 1, -1, -1)):
|
for word, n in zip(numwords, range(len(numwords) - 1, -1, -1)):
|
||||||
self.cards[n] = word
|
self.cards[n] = word
|
||||||
|
|
||||||
|
|
||||||
def splitnum(self, value):
|
def splitnum(self, value):
|
||||||
for elem in self.cards:
|
for elem in self.cards:
|
||||||
if elem > value:
|
if elem > value:
|
||||||
@@ -89,7 +84,6 @@ class Num2Word_Base(object):
|
|||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def to_cardinal(self, value):
|
def to_cardinal(self, value):
|
||||||
try:
|
try:
|
||||||
assert int(value) == value
|
assert int(value) == value
|
||||||
@@ -110,21 +104,20 @@ class Num2Word_Base(object):
|
|||||||
words, num = self.clean(val)
|
words, num = self.clean(val)
|
||||||
return self.title(out + words)
|
return self.title(out + words)
|
||||||
|
|
||||||
|
|
||||||
def float2tuple(self, value):
|
def float2tuple(self, value):
|
||||||
pre = int(value)
|
pre = int(value)
|
||||||
post = abs(value - pre) * 10**self.precision
|
post = abs(value - pre) * 10**self.precision
|
||||||
if abs(round(post) - post) < 0.01:
|
if abs(round(post) - post) < 0.01:
|
||||||
# We generally floor all values beyond our precision (rather than rounding), but in
|
# We generally floor all values beyond our precision (rather than
|
||||||
# cases where we have something like 1.239999999, which is probably due to python's
|
# rounding), but in cases where we have something like 1.239999999,
|
||||||
# handling of floats, we actually want to consider it as 1.24 instead of 1.23
|
# which is probably due to python's handling of floats, we actually
|
||||||
|
# want to consider it as 1.24 instead of 1.23
|
||||||
post = int(round(post))
|
post = int(round(post))
|
||||||
else:
|
else:
|
||||||
post = int(math.floor(post))
|
post = int(math.floor(post))
|
||||||
|
|
||||||
return pre, post
|
return pre, post
|
||||||
|
|
||||||
|
|
||||||
def to_cardinal_float(self, value):
|
def to_cardinal_float(self, value):
|
||||||
try:
|
try:
|
||||||
float(value) == value
|
float(value) == value
|
||||||
@@ -146,11 +139,9 @@ class Num2Word_Base(object):
|
|||||||
|
|
||||||
return " ".join(out)
|
return " ".join(out)
|
||||||
|
|
||||||
|
|
||||||
def merge(self, curr, next):
|
def merge(self, curr, next):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def clean(self, val):
|
def clean(self, val):
|
||||||
out = val
|
out = val
|
||||||
while len(val) != 1:
|
while len(val) != 1:
|
||||||
@@ -172,7 +163,6 @@ class Num2Word_Base(object):
|
|||||||
val = out
|
val = out
|
||||||
return out[0]
|
return out[0]
|
||||||
|
|
||||||
|
|
||||||
def title(self, value):
|
def title(self, value):
|
||||||
if self.is_title:
|
if self.is_title:
|
||||||
out = []
|
out = []
|
||||||
@@ -185,30 +175,24 @@ class Num2Word_Base(object):
|
|||||||
value = " ".join(out)
|
value = " ".join(out)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def verify_ordinal(self, value):
|
def verify_ordinal(self, value):
|
||||||
if not value == int(value):
|
if not value == int(value):
|
||||||
raise TypeError(self.errmsg_floatord % value)
|
raise TypeError(self.errmsg_floatord % value)
|
||||||
if not abs(value) == value:
|
if not abs(value) == value:
|
||||||
raise TypeError(self.errmsg_negord % value)
|
raise TypeError(self.errmsg_negord % value)
|
||||||
|
|
||||||
|
|
||||||
def verify_num(self, value):
|
def verify_num(self, value):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
def set_wordnums(self):
|
def set_wordnums(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def to_ordinal(self, value):
|
def to_ordinal(self, value):
|
||||||
return self.to_cardinal(value)
|
return self.to_cardinal(value)
|
||||||
|
|
||||||
|
|
||||||
def to_ordinal_num(self, value):
|
def to_ordinal_num(self, value):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
# Trivial version
|
# Trivial version
|
||||||
def inflect(self, value, text):
|
def inflect(self, value, text):
|
||||||
text = text.split("/")
|
text = text.split("/")
|
||||||
@@ -216,8 +200,7 @@ class Num2Word_Base(object):
|
|||||||
return text[0]
|
return text[0]
|
||||||
return "".join(text)
|
return "".join(text)
|
||||||
|
|
||||||
|
# //CHECK: generalise? Any others like pounds/shillings/pence?
|
||||||
#//CHECK: generalise? Any others like pounds/shillings/pence?
|
|
||||||
def to_splitnum(self, val, hightxt="", lowtxt="", jointxt="",
|
def to_splitnum(self, val, hightxt="", lowtxt="", jointxt="",
|
||||||
divisor=100, longval=True, cents=True):
|
divisor=100, longval=True, cents=True):
|
||||||
out = []
|
out = []
|
||||||
@@ -252,23 +235,18 @@ class Num2Word_Base(object):
|
|||||||
|
|
||||||
return " ".join(out)
|
return " ".join(out)
|
||||||
|
|
||||||
|
|
||||||
def to_year(self, value, **kwargs):
|
def to_year(self, value, **kwargs):
|
||||||
return self.to_cardinal(value)
|
return self.to_cardinal(value)
|
||||||
|
|
||||||
|
|
||||||
def to_currency(self, value, **kwargs):
|
def to_currency(self, value, **kwargs):
|
||||||
return self.to_cardinal(value)
|
return self.to_cardinal(value)
|
||||||
|
|
||||||
|
|
||||||
def base_setup(self):
|
def base_setup(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test(self, value):
|
def test(self, value):
|
||||||
try:
|
try:
|
||||||
_card = self.to_cardinal(value)
|
_card = self.to_cardinal(value)
|
||||||
@@ -285,5 +263,5 @@ class Num2Word_Base(object):
|
|||||||
except:
|
except:
|
||||||
_ordnum = "invalid"
|
_ordnum = "invalid"
|
||||||
|
|
||||||
print ("For %s, card is %s;\n\tord is %s; and\n\tordnum is %s." %
|
print("For %s, card is %s;\n\tord is %s; and\n\tordnum is %s."
|
||||||
(value, _card, _ord, _ordnum))
|
% (value, _card, _ord, _ordnum))
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ import sys
|
|||||||
|
|
||||||
PY3 = sys.version_info[0] == 3
|
PY3 = sys.version_info[0] == 3
|
||||||
|
|
||||||
|
|
||||||
def to_s(val):
|
def to_s(val):
|
||||||
if PY3:
|
if PY3:
|
||||||
return str(val)
|
return str(val)
|
||||||
else:
|
else:
|
||||||
return unicode(val)
|
return unicode(val)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
from __future__ import division, unicode_literals, print_function
|
from __future__ import division, unicode_literals, print_function
|
||||||
from . import lang_EU
|
from . import lang_EU
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_AR(lang_EU.Num2Word_EU):
|
class Num2Word_AR(lang_EU.Num2Word_EU):
|
||||||
def set_high_numwords(self, high):
|
def set_high_numwords(self, high):
|
||||||
max = 3 + 3*len(high)
|
max = 3 + 3*len(high)
|
||||||
@@ -30,7 +31,7 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
|
|||||||
self.errmsg_nornum = "Only numbers may be converted to words."
|
self.errmsg_nornum = "Only numbers may be converted to words."
|
||||||
self.exclude_title = ["و", "فاصلة", "سالب"]
|
self.exclude_title = ["و", "فاصلة", "سالب"]
|
||||||
|
|
||||||
self.mid_numwords = [(1000000, "مليون"),(1000, "ألف"), (100, "مئة"),
|
self.mid_numwords = [(1000000, "مليون"), (1000, "ألف"), (100, "مئة"),
|
||||||
(90, "تسعين"), (80, "ثمانين"), (70, "سبعين"),
|
(90, "تسعين"), (80, "ثمانين"), (70, "سبعين"),
|
||||||
(60, "ستين"), (50, "خمسين"), (40, "أربعين"),
|
(60, "ستين"), (50, "خمسين"), (40, "أربعين"),
|
||||||
(30, "ثلاثين")]
|
(30, "ثلاثين")]
|
||||||
@@ -39,15 +40,14 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
|
|||||||
"اثناعشر", "أحد عشر", "عشرة", "تسعة", "ثمانية",
|
"اثناعشر", "أحد عشر", "عشرة", "تسعة", "ثمانية",
|
||||||
"سبعة", "ستة", "خمسة", "أربعة", "ثلاثة", "اثنين",
|
"سبعة", "ستة", "خمسة", "أربعة", "ثلاثة", "اثنين",
|
||||||
"واحد", "صفر"]
|
"واحد", "صفر"]
|
||||||
self.ords = { "واحد" : "أول",
|
self.ords = {"واحد": "أول",
|
||||||
"اثنين" : "ثاني",
|
"اثنين": "ثاني",
|
||||||
"ثلاثة" : "ثالث",
|
"ثلاثة": "ثالث",
|
||||||
"أربعة": "رابع",
|
"أربعة": "رابع",
|
||||||
"خمسة" : "خامس",
|
"خمسة": "خامس",
|
||||||
"ثمانية" : "ثامن",
|
"ثمانية": "ثامن",
|
||||||
"تسعة" : "تاسع",
|
"تسعة": "تاسع",
|
||||||
"اثناعشر" : "ثاني عشر" }
|
"اثناعشر": "ثاني عشر" }
|
||||||
|
|
||||||
|
|
||||||
def merge(self, lpair, rpair):
|
def merge(self, lpair, rpair):
|
||||||
ltext, lnum = lpair
|
ltext, lnum = lpair
|
||||||
@@ -68,7 +68,6 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
|
|||||||
return ("%s %s"%(ltext, rtext), lnum * rnum)
|
return ("%s %s"%(ltext, rtext), lnum * rnum)
|
||||||
return ("%s، %s"%(ltext, rtext), lnum + rnum)
|
return ("%s، %s"%(ltext, rtext), lnum + rnum)
|
||||||
|
|
||||||
|
|
||||||
def to_ordinal(self, value):
|
def to_ordinal(self, value):
|
||||||
self.verify_ordinal(value)
|
self.verify_ordinal(value)
|
||||||
outwords = self.to_cardinal(value).split(" ")
|
outwords = self.to_cardinal(value).split(" ")
|
||||||
@@ -82,12 +81,10 @@ class Num2Word_AR(lang_EU.Num2Word_EU):
|
|||||||
outwords[-1] = "،".join(lastwords)
|
outwords[-1] = "،".join(lastwords)
|
||||||
return " ".join(outwords)
|
return " ".join(outwords)
|
||||||
|
|
||||||
|
|
||||||
def to_ordinal_num(self, value):
|
def to_ordinal_num(self, value):
|
||||||
self.verify_ordinal(value)
|
self.verify_ordinal(value)
|
||||||
return "%s%s"%(value, self.to_ordinal(value)[-2:])
|
return "%s%s"%(value, self.to_ordinal(value)[-2:])
|
||||||
|
|
||||||
|
|
||||||
def to_year(self, val, longval=True):
|
def to_year(self, val, longval=True):
|
||||||
if not (val//100)%10:
|
if not (val//100)%10:
|
||||||
return self.to_cardinal(val)
|
return self.to_cardinal(val)
|
||||||
@@ -105,6 +102,7 @@ to_ord = n2w.to_ordinal
|
|||||||
to_ordnum = n2w.to_ordinal_num
|
to_ordnum = n2w.to_ordinal_num
|
||||||
to_year = n2w.to_year
|
to_year = n2w.to_year
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
||||||
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
||||||
@@ -112,7 +110,7 @@ def main():
|
|||||||
-21212121211221211111, -2.121212, -1.0000100]:
|
-21212121211221211111, -2.121212, -1.0000100]:
|
||||||
n2w.test(val)
|
n2w.test(val)
|
||||||
n2w.test(1325325436067876801768700107601001012212132143210473207540327057320957032975032975093275093275093270957329057320975093272950730)
|
n2w.test(1325325436067876801768700107601001012212132143210473207540327057320957032975032975093275093275093270957329057320975093272950730)
|
||||||
for val in [1,120,1000,1120,1800, 1976,2000,2010,2099,2171]:
|
for val in [1, 120, 1000, 1120, 1800, 1976, 2000, 2010, 2099, 2171]:
|
||||||
print(val, "is", n2w.to_currency(val))
|
print(val, "is", n2w.to_currency(val))
|
||||||
print(val, "is", n2w.to_year(val))
|
print(val, "is", n2w.to_year(val))
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
from __future__ import unicode_literals, print_function
|
from __future__ import unicode_literals, print_function
|
||||||
from .lang_EU import Num2Word_EU
|
from .lang_EU import Num2Word_EU
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_DE(Num2Word_EU):
|
class Num2Word_DE(Num2Word_EU):
|
||||||
def set_high_numwords(self, high):
|
def set_high_numwords(self, high):
|
||||||
max = 3 + 6*len(high)
|
max = 3 + 6*len(high)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
from __future__ import division, unicode_literals, print_function
|
from __future__ import division, unicode_literals, print_function
|
||||||
from num2words import lang_EU
|
from num2words import lang_EU
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_DK(lang_EU.Num2Word_EU):
|
class Num2Word_DK(lang_EU.Num2Word_EU):
|
||||||
def set_high_numwords(self, high):
|
def set_high_numwords(self, high):
|
||||||
max = 3 + 6*len(high)
|
max = 3 + 6*len(high)
|
||||||
@@ -138,6 +139,7 @@ to_ord = n2w.to_ordinal
|
|||||||
to_ordnum = n2w.to_ordinal_num
|
to_ordnum = n2w.to_ordinal_num
|
||||||
to_year = n2w.to_year
|
to_year = n2w.to_year
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
||||||
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
from __future__ import division, unicode_literals, print_function
|
from __future__ import division, unicode_literals, print_function
|
||||||
from . import lang_EU
|
from . import lang_EU
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_EN(lang_EU.Num2Word_EU):
|
class Num2Word_EN(lang_EU.Num2Word_EU):
|
||||||
def set_high_numwords(self, high):
|
def set_high_numwords(self, high):
|
||||||
max = 3 + 3*len(high)
|
max = 3 + 3*len(high)
|
||||||
@@ -99,6 +100,7 @@ to_ord = n2w.to_ordinal
|
|||||||
to_ordnum = n2w.to_ordinal_num
|
to_ordnum = n2w.to_ordinal_num
|
||||||
to_year = n2w.to_year
|
to_year = n2w.to_year
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
for val in [ 1, 11, 12, 21, 31, 33, 71, 80, 81, 91, 99, 100, 101, 102, 155,
|
||||||
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
180, 300, 308, 832, 1000, 1001, 1061, 1100, 1500, 1701, 3000,
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ def pluralize(n, forms):
|
|||||||
|
|
||||||
|
|
||||||
def int2word(n):
|
def int2word(n):
|
||||||
if n > 9999: #doesn't yet work for numbers this big
|
if n > 9999: # doesn't yet work for numbers this big
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
if n == 0:
|
if n == 0:
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
from __future__ import unicode_literals, print_function
|
from __future__ import unicode_literals, print_function
|
||||||
from .lang_EU import Num2Word_EU
|
from .lang_EU import Num2Word_EU
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_NL(Num2Word_EU):
|
class Num2Word_NL(Num2Word_EU):
|
||||||
def set_high_numwords(self, high):
|
def set_high_numwords(self, high):
|
||||||
max = 3 + 6*len(high)
|
max = 3 + 6*len(high)
|
||||||
@@ -92,10 +93,10 @@ class Num2Word_NL(Num2Word_EU):
|
|||||||
ntext = "een"
|
ntext = "een"
|
||||||
|
|
||||||
if ntext.endswith("e"):
|
if ntext.endswith("e"):
|
||||||
ntext += "ën"#"n"
|
ntext += "ën" # "n"
|
||||||
else:
|
else:
|
||||||
ntext += "en"
|
ntext += "en"
|
||||||
ntext, ctext = ctext, ntext #+ "en"
|
ntext, ctext = ctext, ntext # + "en"
|
||||||
elif cnum >= 10**6:
|
elif cnum >= 10**6:
|
||||||
ctext += " "
|
ctext += " "
|
||||||
val = cnum + nnum
|
val = cnum + nnum
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ THOUSANDS = {
|
|||||||
6: (u'trylion', u'tryliony', u'trylionów'), # 10^18
|
6: (u'trylion', u'tryliony', u'trylionów'), # 10^18
|
||||||
7: (u'tryliard', u'tryliardy', u'tryliardów'), # 10^21
|
7: (u'tryliard', u'tryliardy', u'tryliardów'), # 10^21
|
||||||
8: (u'kwadrylion', u'kwadryliony', u'kwadrylionów'), # 10^24
|
8: (u'kwadrylion', u'kwadryliony', u'kwadrylionów'), # 10^24
|
||||||
9: (u'kwaryliard', u'kwadryliardy', u'kwadryliardów'), #10^27
|
9: (u'kwaryliard', u'kwadryliardy', u'kwadryliardów'), # 10^27
|
||||||
10: (u'kwintylion', u'kwintyliony', u'kwintylionów'), # 10^30
|
10: (u'kwintylion', u'kwintyliony', u'kwintylionów'), # 10^30
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ THOUSANDS = {
|
|||||||
6: (u'квинтиллион', u'квинтиллиона', u'квинтиллионов'), # 10^18
|
6: (u'квинтиллион', u'квинтиллиона', u'квинтиллионов'), # 10^18
|
||||||
7: (u'секстиллион', u'секстиллиона', u'секстиллионов'), # 10^21
|
7: (u'секстиллион', u'секстиллиона', u'секстиллионов'), # 10^21
|
||||||
8: (u'септиллион', u'септиллиона', u'септиллионов'), # 10^24
|
8: (u'септиллион', u'септиллиона', u'септиллионов'), # 10^24
|
||||||
9: (u'октиллион', u'октиллиона', u'октиллионов'), #10^27
|
9: (u'октиллион', u'октиллиона', u'октиллионов'), # 10^27
|
||||||
10: (u'нониллион', u'нониллиона', u'нониллионов'), # 10^30
|
10: (u'нониллион', u'нониллиона', u'нониллионов'), # 10^30
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ THOUSANDS = {
|
|||||||
6: (u'квiнтильйон', u'квiнтильйони', u'квiнтильйонiв'), # 10^18
|
6: (u'квiнтильйон', u'квiнтильйони', u'квiнтильйонiв'), # 10^18
|
||||||
7: (u'секстильйон', u'секстильйони', u'секстильйонiв'), # 10^21
|
7: (u'секстильйон', u'секстильйони', u'секстильйонiв'), # 10^21
|
||||||
8: (u'септильйон', u'септильйони', u'септильйонiв'), # 10^24
|
8: (u'септильйон', u'септильйони', u'септильйонiв'), # 10^24
|
||||||
9: (u'октильйон', u'октильйони', u'октильйонiв'), #10^27
|
9: (u'октильйон', u'октильйони', u'октильйонiв'), # 10^27
|
||||||
10: (u'нонiльйон', u'нонiльйони', u'нонiльйонiв'), # 10^30
|
10: (u'нонiльйон', u'нонiльйони', u'нонiльйонiв'), # 10^30
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,8 @@ def get_digits(n):
|
|||||||
|
|
||||||
|
|
||||||
def pluralize(n, forms):
|
def pluralize(n, forms):
|
||||||
#form = 0 if n==1 else 1 if (n % 10 > 1 and n % 10 < 5 and (n % 100 < 10 or n % 100 > 20)) else 2
|
# form = 0 if n==1 else 1 if (n % 10 > 1 and n % 10 < 5 and (n % 100 < 10 or
|
||||||
|
# n % 100 > 20)) else 2
|
||||||
if (n % 100 < 10 or n % 100 > 20):
|
if (n % 100 < 10 or n % 100 > 20):
|
||||||
if n % 10 == 1:
|
if n % 10 == 1:
|
||||||
form = 0
|
form = 0
|
||||||
@@ -241,7 +242,7 @@ def int2word(n, feminine=True):
|
|||||||
|
|
||||||
if n2 == 1:
|
if n2 == 1:
|
||||||
words.append(TENS[n1][0])
|
words.append(TENS[n1][0])
|
||||||
#elif n1 > 0 and not (i > 0 and x == 1):
|
# elif n1 > 0 and not (i > 0 and x == 1):
|
||||||
elif n1 > 0:
|
elif n1 > 0:
|
||||||
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])
|
||||||
|
|||||||
Reference in New Issue
Block a user