mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Merge branch 'master' into strings
This commit is contained in:
26
CHANGES.rst
26
CHANGES.rst
@@ -1,6 +1,32 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Version 0.5.9 -- 2019/01/10
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
* Fix encoding issue on release 0.5.8 (#229)
|
||||||
|
* Improve Polish localization (#228)
|
||||||
|
|
||||||
|
|
||||||
|
Version 0.5.8 -- 2018/11/17
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
* Add Portuguese (Portugal) localization (#198)
|
||||||
|
* Add a command line tool to use num2words
|
||||||
|
* Use language iso code for Vietnamese
|
||||||
|
* Improve Korean localization (#219)
|
||||||
|
* Improve Serbian (Latin) localization (#207)
|
||||||
|
* Improve testing setup (#220)
|
||||||
|
* Improve German localization (#214) (#222)
|
||||||
|
* Improve Romanian localization (#215)
|
||||||
|
* Improve Spanish localization (#187) (#200)
|
||||||
|
* Improve Russian localization (#211) (#212)
|
||||||
|
* Improve French localization (23902ab)
|
||||||
|
* Improve Arabic localization (#176)
|
||||||
|
* Improve Lithuanian and Latvian localization (#185)
|
||||||
|
* Improve Ukrainian localization (#183)
|
||||||
|
|
||||||
|
|
||||||
Version 0.5.7 -- 2018/06/27
|
Version 0.5.7 -- 2018/06/27
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ Command line::
|
|||||||
|
|
||||||
$ num2words 10001
|
$ num2words 10001
|
||||||
ten thousand and one
|
ten thousand and one
|
||||||
$ num2words 10123123 --lang es
|
|
||||||
diez millones ciento veintitrés mil ciento veintitrés
|
|
||||||
$ num2words 24,120.10
|
$ num2words 24,120.10
|
||||||
twenty-four thousand, one hundred and twenty point one
|
twenty-four thousand, one hundred and twenty point one
|
||||||
$ num2words 24,120.10 -l es
|
$ num2words 24,120.10 -l es
|
||||||
@@ -97,12 +95,15 @@ Besides the numerical argument, there are two main optional arguments.
|
|||||||
* ``id`` (Indonesian)
|
* ``id`` (Indonesian)
|
||||||
* ``it`` (Italian)
|
* ``it`` (Italian)
|
||||||
* ``ja`` (Japanese)
|
* ``ja`` (Japanese)
|
||||||
|
* ``ko`` (Korean)
|
||||||
* ``lt`` (Lithuanian)
|
* ``lt`` (Lithuanian)
|
||||||
* ``lv`` (Latvian)
|
* ``lv`` (Latvian)
|
||||||
* ``no`` (Norwegian)
|
* ``no`` (Norwegian)
|
||||||
* ``pl`` (Polish)
|
* ``pl`` (Polish)
|
||||||
* ``pt`` (Portuguese)
|
* ``pt`` (Portuguese)
|
||||||
* ``pt_BR`` (Portuguese - Brazilian)
|
* ``pt_BR`` (Portuguese - Brazilian)
|
||||||
|
* ``sl`` (Slovene)
|
||||||
|
* ``sr`` (Serbian)
|
||||||
* ``ro`` (Romanian)
|
* ``ro`` (Romanian)
|
||||||
* ``ru`` (Russian)
|
* ``ru`` (Russian)
|
||||||
* ``sl`` (Slovene)
|
* ``sl`` (Slovene)
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
"""num2words: convert numbers into words.
|
"""num2words: convert numbers into words.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@@ -23,9 +39,6 @@ Examples:
|
|||||||
$ num2words 10001
|
$ num2words 10001
|
||||||
ten thousand and one
|
ten thousand and one
|
||||||
|
|
||||||
$ num2words 10123123 --lang es
|
|
||||||
diez millones ciento veintitrés mil ciento veintitrés
|
|
||||||
|
|
||||||
$ num2words 24,120.10
|
$ num2words 24,120.10
|
||||||
twenty-four thousand, one hundred and twenty point one
|
twenty-four thousand, one hundred and twenty point one
|
||||||
|
|
||||||
@@ -35,13 +48,14 @@ Examples:
|
|||||||
$num2words 2.14 -l es --to currency
|
$num2words 2.14 -l es --to currency
|
||||||
dos euros con catorce centimos
|
dos euros con catorce centimos
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from docopt import docopt
|
from docopt import docopt
|
||||||
import num2words
|
import num2words
|
||||||
|
|
||||||
__version__ = "0.5.7"
|
__version__ = "0.5.9"
|
||||||
__license__ = "LGPL"
|
__license__ = "LGPL"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
version: '3.0'
|
||||||
|
services:
|
||||||
|
web:
|
||||||
|
image: python:3-alpine
|
||||||
|
command: python3 -m http.server 8080
|
||||||
|
volumes:
|
||||||
|
- .:/num2words
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -47,7 +48,9 @@ from . import lang_TR
|
|||||||
from . import lang_NL
|
from . import lang_NL
|
||||||
from . import lang_UK
|
from . import lang_UK
|
||||||
from . import lang_SL
|
from . import lang_SL
|
||||||
|
from . import lang_SR
|
||||||
from . import lang_TH
|
from . import lang_TH
|
||||||
|
from . import lang_KO
|
||||||
|
|
||||||
CONVERTER_CLASSES = {
|
CONVERTER_CLASSES = {
|
||||||
'ar': lang_AR.Num2Word_AR(),
|
'ar': lang_AR.Num2Word_AR(),
|
||||||
@@ -65,12 +68,14 @@ CONVERTER_CLASSES = {
|
|||||||
'es_VE': lang_ES_VE.Num2Word_ES_VE(),
|
'es_VE': lang_ES_VE.Num2Word_ES_VE(),
|
||||||
'id': lang_ID.Num2Word_ID(),
|
'id': lang_ID.Num2Word_ID(),
|
||||||
'ja': lang_JA.Num2Word_JA(),
|
'ja': lang_JA.Num2Word_JA(),
|
||||||
|
'ko': lang_KO.Num2Word_KO(),
|
||||||
'lt': lang_LT.Num2Word_LT(),
|
'lt': lang_LT.Num2Word_LT(),
|
||||||
'lv': lang_LV.Num2Word_LV(),
|
'lv': lang_LV.Num2Word_LV(),
|
||||||
'pl': lang_PL.Num2Word_PL(),
|
'pl': lang_PL.Num2Word_PL(),
|
||||||
'ro': lang_RO.Num2Word_RO(),
|
'ro': lang_RO.Num2Word_RO(),
|
||||||
'ru': lang_RU.Num2Word_RU(),
|
'ru': lang_RU.Num2Word_RU(),
|
||||||
'sl': lang_SL.Num2Word_SL(),
|
'sl': lang_SL.Num2Word_SL(),
|
||||||
|
'sr': lang_SR.Num2Word_SR(),
|
||||||
'no': lang_NO.Num2Word_NO(),
|
'no': lang_NO.Num2Word_NO(),
|
||||||
'dk': lang_DK.Num2Word_DK(),
|
'dk': lang_DK.Num2Word_DK(),
|
||||||
'pt': lang_PT.Num2Word_PT(),
|
'pt': lang_PT.Num2Word_PT(),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2016, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
|
||||||
from decimal import ROUND_HALF_UP, Decimal
|
from decimal import ROUND_HALF_UP, Decimal
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
@@ -130,6 +131,10 @@ class Num2Word_CZ(Num2Word_Base):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from .lang_EU import Num2Word_EU
|
from .lang_EU import Num2Word_EU
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +47,7 @@ class Num2Word_DE(Num2Word_EU):
|
|||||||
self.errmsg_toobig = "Die Zahl %s muss kleiner als %s sein."
|
self.errmsg_toobig = "Die Zahl %s muss kleiner als %s sein."
|
||||||
self.exclude_title = []
|
self.exclude_title = []
|
||||||
|
|
||||||
lows = ["non", "okt", "sept", "sext", "quint", "quadr", "tr", "b", "m"]
|
lows = ["Non", "Okt", "Sept", "Sext", "Quint", "Quadr", "Tr", "B", "M"]
|
||||||
units = ["", "un", "duo", "tre", "quattuor", "quin", "sex", "sept",
|
units = ["", "un", "duo", "tre", "quattuor", "quin", "sex", "sept",
|
||||||
"okto", "novem"]
|
"okto", "novem"]
|
||||||
tens = ["dez", "vigint", "trigint", "quadragint", "quinquagint",
|
tens = ["dez", "vigint", "trigint", "quadragint", "quinquagint",
|
||||||
@@ -78,7 +80,9 @@ class Num2Word_DE(Num2Word_EU):
|
|||||||
ctext, cnum, ntext, nnum = curr + next
|
ctext, cnum, ntext, nnum = curr + next
|
||||||
|
|
||||||
if cnum == 1:
|
if cnum == 1:
|
||||||
if nnum < 10 ** 6:
|
if nnum == 100 or nnum == 1000:
|
||||||
|
return ("ein" + ntext, nnum)
|
||||||
|
elif nnum < 10 ** 6:
|
||||||
return next
|
return next
|
||||||
ctext = "eine"
|
ctext = "eine"
|
||||||
|
|
||||||
@@ -105,26 +109,47 @@ class Num2Word_DE(Num2Word_EU):
|
|||||||
|
|
||||||
def to_ordinal(self, value):
|
def to_ordinal(self, value):
|
||||||
self.verify_ordinal(value)
|
self.verify_ordinal(value)
|
||||||
outword = self.to_cardinal(value)
|
outword = self.to_cardinal(value).lower()
|
||||||
for key in self.ords:
|
for key in self.ords:
|
||||||
if outword.endswith(key):
|
if outword.endswith(key):
|
||||||
outword = outword[:len(outword) - len(key)] + self.ords[key]
|
outword = outword[:len(outword) - len(key)] + self.ords[key]
|
||||||
break
|
break
|
||||||
return outword + "te"
|
|
||||||
|
res = outword + "te"
|
||||||
|
|
||||||
|
# Exception: "hundertste" is usually preferred over "einhundertste"
|
||||||
|
if res == "eintausendste" or res == "einhundertste":
|
||||||
|
res = res.replace("ein", "", 1)
|
||||||
|
# ... similarly for "millionste" etc.
|
||||||
|
res = re.sub(r'eine ([a-z]+(illion|illiard)ste)$',
|
||||||
|
lambda m: m.group(1), res)
|
||||||
|
# Ordinals involving "Million" etc. are written without a space.
|
||||||
|
# see https://de.wikipedia.org/wiki/Million#Sprachliches
|
||||||
|
res = re.sub(r' ([a-z]+(illion|illiard)ste)$',
|
||||||
|
lambda m: m.group(1), res)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def to_ordinal_num(self, value):
|
def to_ordinal_num(self, value):
|
||||||
self.verify_ordinal(value)
|
self.verify_ordinal(value)
|
||||||
return str(value) + "."
|
return str(value) + "."
|
||||||
|
|
||||||
def to_currency(self, val, longval=True, old=False):
|
def to_currency(self, val, longval=True, old=False):
|
||||||
hightxt = "euro"
|
hightxt = "Euro"
|
||||||
lowtxt = "cent"
|
lowtxt = "Cent"
|
||||||
if old:
|
if old:
|
||||||
hightxt = "mark"
|
hightxt = "Mark"
|
||||||
lowtxt = "pfennig/e"
|
lowtxt = "Pfennig/e"
|
||||||
|
|
||||||
return self.to_splitnum(val, hightxt=hightxt, lowtxt=lowtxt,
|
cents = int(round(val*100))
|
||||||
jointxt="und", longval=longval)
|
res = self.to_splitnum(cents, hightxt=hightxt, lowtxt=lowtxt,
|
||||||
|
jointxt="und", longval=longval)
|
||||||
|
|
||||||
|
# Handle exception, in german is "ein Euro" and not "eins Euro"
|
||||||
|
if res.startswith("eins "):
|
||||||
|
res = res.replace("eins ", "ein ", 1)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def to_year(self, val, longval=True):
|
def to_year(self, val, longval=True):
|
||||||
if not (val // 100) % 10:
|
if not (val // 100) % 10:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ class Num2Word_FR(Num2Word_EU):
|
|||||||
def to_ordinal_num(self, value):
|
def to_ordinal_num(self, value):
|
||||||
self.verify_ordinal(value)
|
self.verify_ordinal(value)
|
||||||
out = str(value)
|
out = str(value)
|
||||||
out += {"1": "er"}.get(out[-1], "me")
|
out += "er" if value == 1 else "me"
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def to_currency(self, val, longval=True, old=False):
|
def to_currency(self, val, longval=True, old=False):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
from .lang_FR import Num2Word_FR
|
from .lang_FR import Num2Word_FR
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -94,9 +94,11 @@ def int2word(n):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
n1, n2, n3 = get_digits(x)
|
|
||||||
|
|
||||||
# print str(n3) + str(n2) + str(n1)
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
if n3 <= 2:
|
if n3 <= 2:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
# License as published by the Free Software Foundation; either
|
# License as published by the Free Software Foundation; either
|
||||||
|
|||||||
148
num2words/lang_KO.py
Normal file
148
num2words/lang_KO.py
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
from __future__ import division, print_function, unicode_literals
|
||||||
|
|
||||||
|
from .base import Num2Word_Base
|
||||||
|
from .currency import parse_currency_parts
|
||||||
|
|
||||||
|
|
||||||
|
class Num2Word_KO(Num2Word_Base):
|
||||||
|
CURRENCY_FORMS = {
|
||||||
|
'KRW': ('원', None),
|
||||||
|
'USD': ('달러', '센트'),
|
||||||
|
'JPY': ('엔', None)
|
||||||
|
}
|
||||||
|
|
||||||
|
def set_high_numwords(self, high):
|
||||||
|
max = 4 * len(high)
|
||||||
|
for word, n in zip(high, range(max, 0, -4)):
|
||||||
|
self.cards[10 ** n] = word
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
super(Num2Word_KO, self).setup()
|
||||||
|
|
||||||
|
self.negword = "마이너스 "
|
||||||
|
self.pointword = "점"
|
||||||
|
|
||||||
|
self.high_numwords = [
|
||||||
|
'무량대수',
|
||||||
|
'불가사의',
|
||||||
|
'나유타',
|
||||||
|
'아승기',
|
||||||
|
'항하사',
|
||||||
|
'극',
|
||||||
|
'재',
|
||||||
|
'정',
|
||||||
|
'간',
|
||||||
|
'구',
|
||||||
|
'양',
|
||||||
|
'자',
|
||||||
|
'해',
|
||||||
|
'경',
|
||||||
|
'조',
|
||||||
|
'억',
|
||||||
|
'만']
|
||||||
|
self.mid_numwords = [(1000, "천"), (100, "백")]
|
||||||
|
self.low_numwords = ["십", "구", "팔", "칠", "육", "오", "사", "삼", "이",
|
||||||
|
"일", "영"]
|
||||||
|
self.ords = {"일": "한",
|
||||||
|
"이": "두",
|
||||||
|
"삼": "세",
|
||||||
|
"사": "네",
|
||||||
|
"오": "다섯",
|
||||||
|
"육": "여섯",
|
||||||
|
"칠": "일곱",
|
||||||
|
"팔": "여덟",
|
||||||
|
"구": "아홉",
|
||||||
|
"십": "열",
|
||||||
|
"이십": "스물",
|
||||||
|
"삼십": "서른",
|
||||||
|
"사십": "마흔",
|
||||||
|
"오십": "쉰",
|
||||||
|
"육십": "예순",
|
||||||
|
"칠십": "일흔",
|
||||||
|
"팔십": "여든",
|
||||||
|
"구십": "아흔"}
|
||||||
|
|
||||||
|
def merge(self, lpair, rpair):
|
||||||
|
ltext, lnum = lpair
|
||||||
|
rtext, rnum = rpair
|
||||||
|
if lnum == 1 and rnum <= 10000:
|
||||||
|
return rpair
|
||||||
|
elif 10000 > lnum > rnum:
|
||||||
|
return ("%s%s" % (ltext, rtext), lnum + rnum)
|
||||||
|
elif lnum >= 10000 and lnum > rnum:
|
||||||
|
return ("%s %s" % (ltext, rtext), lnum + rnum)
|
||||||
|
else:
|
||||||
|
return ("%s%s" % (ltext, rtext), lnum * rnum)
|
||||||
|
|
||||||
|
def to_ordinal(self, value):
|
||||||
|
self.verify_ordinal(value)
|
||||||
|
if(value == 1):
|
||||||
|
return "첫 번째"
|
||||||
|
outwords = self.to_cardinal(value).split(" ")
|
||||||
|
lastwords = outwords[-1].split("백")
|
||||||
|
if "십" in lastwords[-1]:
|
||||||
|
ten_one = lastwords[-1].split("십")
|
||||||
|
ten_one[0] = self.ords[ten_one[0] + "십"]
|
||||||
|
try:
|
||||||
|
ten_one[1] = self.ords[ten_one[1]]
|
||||||
|
ten_one[0] = ten_one[0].replace("스무", "스물")
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
lastwords[-1] = ''.join(ten_one)
|
||||||
|
else:
|
||||||
|
lastwords[-1] = self.ords[lastwords[-1]]
|
||||||
|
outwords[-1] = "백 ".join(lastwords)
|
||||||
|
return " ".join(outwords) + " 번째"
|
||||||
|
|
||||||
|
def to_ordinal_num(self, value):
|
||||||
|
self.verify_ordinal(value)
|
||||||
|
return "%s 번째" % (value)
|
||||||
|
|
||||||
|
def to_year(self, val, suffix=None, longval=True):
|
||||||
|
if val < 0:
|
||||||
|
val = abs(val)
|
||||||
|
suffix = '기원전' if not suffix else suffix
|
||||||
|
valtext = self.to_cardinal(val)
|
||||||
|
return ("%s년" % valtext if not suffix
|
||||||
|
else "%s %s년" % (suffix, valtext))
|
||||||
|
|
||||||
|
def to_currency(self, val, currency="KRW", cents=False, seperator="",
|
||||||
|
adjective=False):
|
||||||
|
left, right, is_negative = parse_currency_parts(
|
||||||
|
val, is_int_with_cents=cents)
|
||||||
|
|
||||||
|
try:
|
||||||
|
cr1, cr2 = self.CURRENCY_FORMS[currency]
|
||||||
|
if (cents or right) and not cr2:
|
||||||
|
raise ValueError('Decimals not supported for "%s"' % currency)
|
||||||
|
except KeyError:
|
||||||
|
raise NotImplementedError(
|
||||||
|
'Currency code "%s" not implemented for "%s"' %
|
||||||
|
(currency, self.__class__.__name__))
|
||||||
|
|
||||||
|
minus_str = self.negword if is_negative else ""
|
||||||
|
return '%s%s%s%s%s' % (
|
||||||
|
minus_str,
|
||||||
|
''.join(self.to_cardinal(left).split()),
|
||||||
|
cr1,
|
||||||
|
' ' + self.to_cardinal(right)
|
||||||
|
if cr2 else '',
|
||||||
|
cr2 if cr2 else '',
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
# TODO: replace WINDOWS line endings to UNIX?
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
@@ -149,6 +149,10 @@ class Num2Word_LT(Num2Word_Base):
|
|||||||
|
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
# TODO: replace WINDOWS line endings to UNIX?
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
@@ -157,6 +157,10 @@ class Num2Word_LV(Num2Word_Base):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
@@ -176,7 +180,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 i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,8 +14,11 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import itertools
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
from .utils import get_digits, splitbyx
|
from .utils import get_digits, splitbyx
|
||||||
|
|
||||||
@@ -66,22 +69,31 @@ HUNDREDS = {
|
|||||||
6: ('sześćset',),
|
6: ('sześćset',),
|
||||||
7: ('siedemset',),
|
7: ('siedemset',),
|
||||||
8: ('osiemset',),
|
8: ('osiemset',),
|
||||||
9: ('dziewęćset',),
|
9: ('dziewięćset',),
|
||||||
}
|
}
|
||||||
|
|
||||||
THOUSANDS = {
|
THOUSANDS = {
|
||||||
1: ('tysiąc', 'tysiące', 'tysięcy'), # 10^3
|
1: ('tysiąc', 'tysiące', 'tysięcy'), # 10^3
|
||||||
2: ('milion', 'miliony', 'milionów'), # 10^6
|
|
||||||
3: ('miliard', 'miliardy', 'miliardów'), # 10^9
|
|
||||||
4: ('bilion', 'biliony', 'bilionów'), # 10^12
|
|
||||||
5: ('biliard', 'biliardy', 'biliardów'), # 10^15
|
|
||||||
6: ('trylion', 'tryliony', 'trylionów'), # 10^18
|
|
||||||
7: ('tryliard', 'tryliardy', 'tryliardów'), # 10^21
|
|
||||||
8: ('kwadrylion', 'kwadryliony', 'kwadrylionów'), # 10^24
|
|
||||||
9: ('kwaryliard', 'kwadryliardy', 'kwadryliardów'), # 10^27
|
|
||||||
10: ('kwintylion', 'kwintyliony', 'kwintylionów'), # 10^30
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefixes = ( # 10^(6*x)
|
||||||
|
"mi", # 10^6
|
||||||
|
"bi", # 10^12
|
||||||
|
"try", # 10^18
|
||||||
|
"kwadry", # 10^24
|
||||||
|
"kwinty", # 10^30
|
||||||
|
"seksty", # 10^36
|
||||||
|
"septy", # 10^42
|
||||||
|
"okty", # 10^48
|
||||||
|
"nony", # 10^54
|
||||||
|
"decy" # 10^60
|
||||||
|
)
|
||||||
|
suffixes = ("lion", "liard") # 10^x or 10^(x+3)
|
||||||
|
|
||||||
|
for idx, (p, s) in enumerate(itertools.product(prefixes, suffixes)):
|
||||||
|
name = p + s
|
||||||
|
THOUSANDS[idx+2] = (name, name + 'y', name + 'ów')
|
||||||
|
|
||||||
|
|
||||||
class Num2Word_PL(Num2Word_Base):
|
class Num2Word_PL(Num2Word_Base):
|
||||||
CURRENCY_FORMS = {
|
CURRENCY_FORMS = {
|
||||||
@@ -130,6 +142,10 @@ class Num2Word_PL(Num2Word_Base):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -15,7 +14,6 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import division, unicode_literals
|
from __future__ import division, unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
@@ -209,6 +210,10 @@ class Num2Word_RU(Num2Word_Base):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
@@ -223,7 +228,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 i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .lang_EU import Num2Word_EU
|
from .lang_EU import Num2Word_EU
|
||||||
|
|||||||
216
num2words/lang_SR.py
Normal file
216
num2words/lang_SR.py
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from .base import Num2Word_Base
|
||||||
|
from .currency import parse_currency_parts, prefix_currency
|
||||||
|
from .utils import get_digits, splitbyx
|
||||||
|
|
||||||
|
ZERO = ('nula',)
|
||||||
|
|
||||||
|
ONES = {
|
||||||
|
1: ('jedan', 'jedna'),
|
||||||
|
2: ('dva', 'dve'),
|
||||||
|
3: ('tri', 'tri'),
|
||||||
|
4: ('četiri', 'četiri'),
|
||||||
|
5: ('pet', 'pet'),
|
||||||
|
6: ('šest', 'šest'),
|
||||||
|
7: ('sedam', 'sedam'),
|
||||||
|
8: ('osam', 'osam'),
|
||||||
|
9: ('devet', 'devet'),
|
||||||
|
}
|
||||||
|
|
||||||
|
TENS = {
|
||||||
|
0: ('deset',),
|
||||||
|
1: ('jedanaest',),
|
||||||
|
2: ('dvanaest',),
|
||||||
|
3: ('trinaest',),
|
||||||
|
4: ('četrnaest',),
|
||||||
|
5: ('petnaest',),
|
||||||
|
6: ('šesnaest',),
|
||||||
|
7: ('sedamnaest',),
|
||||||
|
8: ('osamnaest',),
|
||||||
|
9: ('devetnaest',),
|
||||||
|
}
|
||||||
|
|
||||||
|
TWENTIES = {
|
||||||
|
2: ('dvadeset',),
|
||||||
|
3: ('trideset',),
|
||||||
|
4: ('četrdeset',),
|
||||||
|
5: ('pedeset',),
|
||||||
|
6: ('šezdeset',),
|
||||||
|
7: ('sedamdeset',),
|
||||||
|
8: ('osamdeset',),
|
||||||
|
9: ('devedeset',),
|
||||||
|
}
|
||||||
|
|
||||||
|
HUNDREDS = {
|
||||||
|
1: ('sto',),
|
||||||
|
2: ('dvesta',),
|
||||||
|
3: ('trista',),
|
||||||
|
4: ('četristo',),
|
||||||
|
5: ('petsto',),
|
||||||
|
6: ('šesto',),
|
||||||
|
7: ('sedamsto',),
|
||||||
|
8: ('osamsto',),
|
||||||
|
9: ('devetsto',),
|
||||||
|
}
|
||||||
|
|
||||||
|
SCALE = {
|
||||||
|
0: ('', '', '', False),
|
||||||
|
1: ('hiljada', 'hiljade', 'hiljada', True), # 10^3
|
||||||
|
2: ('milion', 'miliona', 'miliona', False), # 10^6
|
||||||
|
3: ('bilion', 'biliona', 'biliona', False), # 10^9
|
||||||
|
4: ('trilion', 'triliona', 'triliona', False), # 10^12
|
||||||
|
5: ('kvadrilion', 'kvadriliona', 'kvadriliona', False), # 10^15
|
||||||
|
6: ('kvintilion', 'kvintiliona', 'kvintiliona', False), # 10^18
|
||||||
|
7: ('sekstilion', 'sekstiliona', 'sekstiliona', False), # 10^21
|
||||||
|
8: ('septilion', 'septiliona', 'septiliona', False), # 10^24
|
||||||
|
9: ('oktilion', 'oktiliona', 'oktiliona', False), # 10^27
|
||||||
|
10: ('nonilion', 'noniliona', 'noniliona', False), # 10^30
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Num2Word_SR(Num2Word_Base):
|
||||||
|
CURRENCY_FORMS = {
|
||||||
|
'RUB': (
|
||||||
|
('rublja', 'rublje', 'rublji', True),
|
||||||
|
('kopejka', 'kopejke', 'kopejki', True)
|
||||||
|
),
|
||||||
|
'EUR': (
|
||||||
|
('evro', 'evra', 'evra', False),
|
||||||
|
('cent', 'centa', 'centi', False)
|
||||||
|
),
|
||||||
|
'RSD': (
|
||||||
|
('dinar', 'dinara', 'dinara', False),
|
||||||
|
('para', 'pare', 'para', True)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
self.negword = "minus"
|
||||||
|
self.pointword = "zapeta"
|
||||||
|
|
||||||
|
def to_cardinal(self, number, feminine=False):
|
||||||
|
n = str(number).replace(',', '.')
|
||||||
|
if '.' in n:
|
||||||
|
left, right = n.split('.')
|
||||||
|
return u'%s %s %s' % (
|
||||||
|
self._int2word(int(left), feminine),
|
||||||
|
self.pointword,
|
||||||
|
self._int2word(int(right), feminine)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return self._int2word(int(n), feminine)
|
||||||
|
|
||||||
|
def pluralize(self, number, forms):
|
||||||
|
if number % 100 < 10 or number % 100 > 20:
|
||||||
|
if number % 10 == 1:
|
||||||
|
form = 0
|
||||||
|
elif 1 < number % 10 < 5:
|
||||||
|
form = 1
|
||||||
|
else:
|
||||||
|
form = 2
|
||||||
|
else:
|
||||||
|
form = 2
|
||||||
|
return forms[form]
|
||||||
|
|
||||||
|
def to_ordinal(self, number):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def _cents_verbose(self, number, currency):
|
||||||
|
return self._int2word(
|
||||||
|
number,
|
||||||
|
self.CURRENCY_FORMS[currency][1][-1]
|
||||||
|
)
|
||||||
|
|
||||||
|
def _int2word(self, number, feminine=False):
|
||||||
|
if number < 0:
|
||||||
|
return ' '.join([self.negword, self._int2word(abs(number))])
|
||||||
|
|
||||||
|
if number == 0:
|
||||||
|
return ZERO[0]
|
||||||
|
|
||||||
|
words = []
|
||||||
|
chunks = list(splitbyx(str(number), 3))
|
||||||
|
chunk_len = len(chunks)
|
||||||
|
for chunk in chunks:
|
||||||
|
chunk_len -= 1
|
||||||
|
digit_right, digit_mid, digit_left = get_digits(chunk)
|
||||||
|
|
||||||
|
if digit_left > 0:
|
||||||
|
words.append(HUNDREDS[digit_left][0])
|
||||||
|
|
||||||
|
if digit_mid > 1:
|
||||||
|
words.append(TWENTIES[digit_mid][0])
|
||||||
|
|
||||||
|
if digit_mid == 1:
|
||||||
|
words.append(TENS[digit_right][0])
|
||||||
|
elif digit_right > 0:
|
||||||
|
is_feminine = feminine or SCALE[chunk_len][-1]
|
||||||
|
gender_idx = int(is_feminine)
|
||||||
|
words.append(
|
||||||
|
ONES[digit_right][gender_idx]
|
||||||
|
)
|
||||||
|
|
||||||
|
if chunk_len > 0 and chunk != 0:
|
||||||
|
words.append(self.pluralize(chunk, SCALE[chunk_len]))
|
||||||
|
|
||||||
|
return ' '.join(words)
|
||||||
|
|
||||||
|
def to_currency(self, val, currency='EUR', cents=True, seperator=',',
|
||||||
|
adjective=False):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
val: Numeric value
|
||||||
|
currency (str): Currency code
|
||||||
|
cents (bool): Verbose cents
|
||||||
|
seperator (str): Cent seperator
|
||||||
|
adjective (bool): Prefix currency name with adjective
|
||||||
|
Returns:
|
||||||
|
str: Formatted string
|
||||||
|
|
||||||
|
"""
|
||||||
|
left, right, is_negative = parse_currency_parts(val)
|
||||||
|
|
||||||
|
try:
|
||||||
|
cr1, cr2 = self.CURRENCY_FORMS[currency]
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
raise NotImplementedError(
|
||||||
|
'Currency code "%s" not implemented for "%s"' %
|
||||||
|
(currency, self.__class__.__name__))
|
||||||
|
|
||||||
|
if adjective and currency in self.CURRENCY_ADJECTIVES:
|
||||||
|
cr1 = prefix_currency(
|
||||||
|
self.CURRENCY_ADJECTIVES[currency],
|
||||||
|
cr1
|
||||||
|
)
|
||||||
|
|
||||||
|
minus_str = "%s " % self.negword if is_negative else ""
|
||||||
|
cents_str = self._cents_verbose(right, currency) \
|
||||||
|
if cents else self._cents_terse(right, currency)
|
||||||
|
|
||||||
|
return u'%s%s %s%s %s %s' % (
|
||||||
|
minus_str,
|
||||||
|
self.to_cardinal(left, feminine=cr1[-1]),
|
||||||
|
self.pluralize(left, cr1),
|
||||||
|
seperator,
|
||||||
|
cents_str,
|
||||||
|
self.pluralize(right, cr2)
|
||||||
|
)
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
# Copyright (c) 2017, Tufan Kaynak, Framras. All Rights Reserved.
|
# Copyright (c) 2017, Tufan Kaynak, Framras. All Rights Reserved.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .base import Num2Word_Base
|
from .base import Num2Word_Base
|
||||||
@@ -147,6 +148,10 @@ class Num2Word_UK(Num2Word_Base):
|
|||||||
i = len(chunks)
|
i = len(chunks)
|
||||||
for x in chunks:
|
for x in chunks:
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
n1, n2, n3 = get_digits(x)
|
n1, n2, n3 = get_digits(x)
|
||||||
|
|
||||||
if n3 > 0:
|
if n3 > 0:
|
||||||
@@ -162,7 +167,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 i > 0:
|
||||||
words.append(self.pluralize(x, THOUSANDS[i]))
|
words.append(self.pluralize(x, THOUSANDS[i]))
|
||||||
|
|
||||||
return ' '.join(words)
|
return ' '.join(words)
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
def splitbyx(n, x, format_int=True):
|
def splitbyx(n, x, format_int=True):
|
||||||
length = len(n)
|
length = len(n)
|
||||||
if length > x:
|
if length > x:
|
||||||
|
|||||||
24
setup.py
24
setup.py
@@ -1,4 +1,22 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from io import open
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
@@ -17,8 +35,8 @@ CLASSIFIERS = [
|
|||||||
'Topic :: Text Processing :: Linguistic',
|
'Topic :: Text Processing :: Linguistic',
|
||||||
]
|
]
|
||||||
|
|
||||||
LONG_DESC = open('README.rst', 'rt').read() + '\n\n' + \
|
LONG_DESC = open('README.rst', 'rt', encoding="utf-8").read() + '\n\n' + \
|
||||||
open('CHANGES.rst', 'rt').read()
|
open('CHANGES.rst', 'rt', encoding="utf-8").read()
|
||||||
|
|
||||||
|
|
||||||
def find_version(fname):
|
def find_version(fname):
|
||||||
@@ -26,7 +44,7 @@ def find_version(fname):
|
|||||||
Returns str or raises RuntimeError
|
Returns str or raises RuntimeError
|
||||||
"""
|
"""
|
||||||
version = ''
|
version = ''
|
||||||
with open(fname, 'r') as fp:
|
with open(fname, 'r', encoding="utf-8") as fp:
|
||||||
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
|
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
|
||||||
for line in fp:
|
for line in fp:
|
||||||
m = reg.match(line)
|
m = reg.match(line)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
# from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -22,7 +23,10 @@ from num2words import num2words
|
|||||||
|
|
||||||
|
|
||||||
class Num2WordsDETest(TestCase):
|
class Num2WordsDETest(TestCase):
|
||||||
|
|
||||||
def test_ordinal_less_than_twenty(self):
|
def test_ordinal_less_than_twenty(self):
|
||||||
|
self.assertEqual(num2words(0, ordinal=True, lang='de'), "nullte")
|
||||||
|
self.assertEqual(num2words(1, ordinal=True, lang='de'), "erste")
|
||||||
self.assertEqual(num2words(7, ordinal=True, lang='de'), "siebte")
|
self.assertEqual(num2words(7, ordinal=True, lang='de'), "siebte")
|
||||||
self.assertEqual(num2words(8, ordinal=True, lang='de'), "achte")
|
self.assertEqual(num2words(8, ordinal=True, lang='de'), "achte")
|
||||||
self.assertEqual(num2words(12, ordinal=True, lang='de'), "zwölfte")
|
self.assertEqual(num2words(12, ordinal=True, lang='de'), "zwölfte")
|
||||||
@@ -44,17 +48,28 @@ class Num2WordsDETest(TestCase):
|
|||||||
num2words(4000, ordinal=True, lang='de'), "viertausendste"
|
num2words(4000, ordinal=True, lang='de'), "viertausendste"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
num2words(2000000, ordinal=True, lang='de'), "zwei millionste"
|
num2words(1000000, ordinal=True, lang='de'), "millionste"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
num2words(2000000, ordinal=True, lang='de'), "zweimillionste"
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
num2words(1000000000, ordinal=True, lang='de'), "milliardste"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
num2words(5000000000, ordinal=True, lang='de'),
|
num2words(5000000000, ordinal=True, lang='de'),
|
||||||
"fünf milliardste"
|
"fünfmilliardste"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_cardinal_at_some_numbers(self):
|
def test_cardinal_at_some_numbers(self):
|
||||||
self.assertEqual(num2words(2000000, lang='de'), "zwei millionen")
|
self.assertEqual(num2words(100, lang='de'), "einhundert")
|
||||||
self.assertEqual(num2words(4000000000, lang='de'), "vier milliarden")
|
self.assertEqual(num2words(1000, lang='de'), "eintausend")
|
||||||
self.assertEqual(num2words(1000000000, lang='de'), "eine milliarde")
|
self.assertEqual(num2words(5000, lang='de'), "fünftausend")
|
||||||
|
self.assertEqual(num2words(10000, lang='de'), "zehntausend")
|
||||||
|
self.assertEqual(num2words(1000000, lang='de'), "eine Million")
|
||||||
|
self.assertEqual(num2words(2000000, lang='de'), "zwei Millionen")
|
||||||
|
self.assertEqual(num2words(4000000000, lang='de'), "vier Milliarden")
|
||||||
|
self.assertEqual(num2words(1000000000, lang='de'), "eine Milliarde")
|
||||||
|
|
||||||
def test_cardinal_for_decimal_number(self):
|
def test_cardinal_for_decimal_number(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@@ -64,8 +79,8 @@ class Num2WordsDETest(TestCase):
|
|||||||
def test_giant_cardinal_for_merge(self):
|
def test_giant_cardinal_for_merge(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
num2words(4500072900000111, lang='de'),
|
num2words(4500072900000111, lang='de'),
|
||||||
"vier billiarden fünfhundert billionen " +
|
"vier Billiarden fünfhundert Billionen " +
|
||||||
"zweiundsiebzig milliarden neunhundert millionen hundertelf"
|
"zweiundsiebzig Milliarden neunhundert Millionen einhundertelf"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_ordinal_num(self):
|
def test_ordinal_num(self):
|
||||||
@@ -79,12 +94,28 @@ class Num2WordsDETest(TestCase):
|
|||||||
self.assertRaises(TypeError, num2words, 2.453, ordinal=True, lang='de')
|
self.assertRaises(TypeError, num2words, 2.453, ordinal=True, lang='de')
|
||||||
|
|
||||||
def test_currency(self):
|
def test_currency(self):
|
||||||
self.assertEqual(num2words(12.00, to='currency', lang='de'),
|
self.assertEqual(num2words(1, lang='de', to='currency'),
|
||||||
'zwölf euro')
|
'ein Euro')
|
||||||
|
self.assertEqual(num2words(12, lang='de', to='currency'),
|
||||||
|
'zwölf Euro')
|
||||||
|
self.assertEqual(num2words(12.00, lang='de', to='currency'),
|
||||||
|
'zwölf Euro')
|
||||||
|
self.assertEqual(num2words(100.0, lang='de', to='currency'),
|
||||||
|
"einhundert Euro")
|
||||||
|
self.assertEqual(num2words(190, lang='de', to='currency'),
|
||||||
|
"einhundertneunzig Euro")
|
||||||
|
self.assertEqual(num2words(1.90, lang='de', to='currency'),
|
||||||
|
"ein Euro und neunzig Cent")
|
||||||
|
self.assertEqual(num2words(3.4, lang='de', to='currency'),
|
||||||
|
"drei Euro und vierzig Cent")
|
||||||
|
self.assertEqual(num2words(20.18, lang='de', to='currency'),
|
||||||
|
"zwanzig Euro und achtzehn Cent")
|
||||||
|
self.assertEqual(num2words(3.04, lang='de', to='currency'),
|
||||||
|
"drei Euro und vier Cent")
|
||||||
|
|
||||||
def test_old_currency(self):
|
def test_old_currency(self):
|
||||||
self.assertEqual(num2words(12.00, to='currency', lang='de', old=True),
|
self.assertEqual(num2words(12.00, to='currency', lang='de', old=True),
|
||||||
'zwölf mark')
|
'zwölf Mark')
|
||||||
|
|
||||||
def test_year(self):
|
def test_year(self):
|
||||||
self.assertEqual(num2words(2002, to='year', lang='de'),
|
self.assertEqual(num2words(2002, to='year', lang='de'),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# encoding: UTF-8
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from num2words import num2words
|
from num2words import num2words
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copetright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This libraret is free software; etou can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modifet it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
# License as published bet the Free Software Foundation; either
|
# License as published by the Free Software Foundation; either
|
||||||
# version 2.1 of the License, or (at etour option) anet later version.
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
# This libraret is distributed in the hope that it will be useful,
|
# This library is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warrantet of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
# Lesser General Public License for more details.
|
# Lesser General Public License for more details.
|
||||||
# You should have received a copet of the GNU Lesser General Public
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
# License along with this libraret; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
@@ -107,10 +107,13 @@ TEST_CASES_ORDINAL = (
|
|||||||
TEST_CASES_ORDINAL_NUM = (
|
TEST_CASES_ORDINAL_NUM = (
|
||||||
(1, '1er'),
|
(1, '1er'),
|
||||||
(8, '8me'),
|
(8, '8me'),
|
||||||
|
(11, '11me'),
|
||||||
(12, '12me'),
|
(12, '12me'),
|
||||||
(14, '14me'),
|
(14, '14me'),
|
||||||
|
(21, '21me'),
|
||||||
(28, '28me'),
|
(28, '28me'),
|
||||||
(100, '100me'),
|
(100, '100me'),
|
||||||
|
(101, '101me'),
|
||||||
(1000, '1000me'),
|
(1000, '1000me'),
|
||||||
(1000000, '1000000me')
|
(1000000, '1000000me')
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -13,7 +14,6 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
93
tests/test_ko.py
Normal file
93
tests/test_ko.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
from __future__ import division, print_function, unicode_literals
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from num2words import num2words
|
||||||
|
|
||||||
|
|
||||||
|
def n2k(*args, **kwargs):
|
||||||
|
return num2words(*args, lang='ko', **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class Num2WordsKOTest(TestCase):
|
||||||
|
def test_low(self):
|
||||||
|
cases = [(0, "영"), (1, "일"), (2, "이"), (3, "삼"), (4, "사"), (5, "오"),
|
||||||
|
(6, "육"), (7, "칠"), (8, "팔"), (9, "구"), (10, "십"),
|
||||||
|
(11, "십일"), (12, "십이"), (13, "십삼"), (14, "십사"),
|
||||||
|
(15, "십오"), (16, "십육"), (17, "십칠"),
|
||||||
|
(18, "십팔"), (19, "십구"), (20, "이십"), (25, "이십오"),
|
||||||
|
(31, "삼십일"), (42, "사십이"), (54, "오십사"), (63, "육십삼"),
|
||||||
|
(76, "칠십육"), (89, "팔십구"), (98, "구십팔")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num), out)
|
||||||
|
|
||||||
|
def test_mid(self):
|
||||||
|
cases = [(100, "백"), (121, "백이십일"), (160, "백육십"), (256, "이백오십육"),
|
||||||
|
(285, "이백팔십오"), (486, "사백팔십육"), (627, "육백이십칠"),
|
||||||
|
(808, "팔백팔"), (999, "구백구십구"), (1004, "천사"),
|
||||||
|
(2018, "이천십팔"), (7063, "칠천육십삼")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num), out)
|
||||||
|
|
||||||
|
def test_high(self):
|
||||||
|
cases = [(10000, "만"), (11020, "만 천이십"), (25891, "이만 오천팔백구십일"),
|
||||||
|
(64237, "육만 사천이백삼십칠"), (241572, "이십사만 천오백칠십이"),
|
||||||
|
(100000000, "일억"), (5000500000000, "오조 오억")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num), out)
|
||||||
|
|
||||||
|
def test_negative(self):
|
||||||
|
cases = [(-11, "마이너스 십일"), (-15, "마이너스 십오"),
|
||||||
|
(-18, "마이너스 십팔"), (-241572, "마이너스 이십사만 천오백칠십이")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num), out)
|
||||||
|
|
||||||
|
def test_year(self):
|
||||||
|
cases = [(2000, "이천년"), (2002, "이천이년"), (2018, "이천십팔년"),
|
||||||
|
(1954, "천구백오십사년"), (1910, "천구백십년"), (-1000, "기원전 천년")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num, to="year"), out)
|
||||||
|
|
||||||
|
def test_currency(self):
|
||||||
|
cases_krw = [(8350, "팔천삼백오십원"), (14980, "만사천구백팔십원"),
|
||||||
|
(250004000, "이억오천만사천원")]
|
||||||
|
cases_usd = [(4, "사달러 영센트"), (19.55, "십구달러 오십오센트")]
|
||||||
|
cases_jpy = [(15, "십오엔"), (50, "오십엔")]
|
||||||
|
for num, out in cases_krw:
|
||||||
|
self.assertEqual(n2k(num, to="currency"), out)
|
||||||
|
for num, out in cases_usd:
|
||||||
|
self.assertEqual(n2k(num, to="currency", currency="USD"), out)
|
||||||
|
for num, out in cases_jpy:
|
||||||
|
self.assertEqual(n2k(num, to="currency", currency="JPY"), out)
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
n2k(190.55, to="currency")
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
n2k(4, to="currency", currency="EUR")
|
||||||
|
|
||||||
|
def test_ordinal(self):
|
||||||
|
cases = [(1, "첫 번째"), (101, "백 한 번째"), (2, "두 번째"), (5, "다섯 번째"),
|
||||||
|
(10, "열 번째"), (25, "스물다섯 번째"), (137, "백 서른일곱 번째")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num, to="ordinal"), out)
|
||||||
|
|
||||||
|
def test_ordinal_num(self):
|
||||||
|
cases = [(1, "1 번째"), (101, "101 번째"), (25, "25 번째")]
|
||||||
|
for num, out in cases:
|
||||||
|
self.assertEqual(n2k(num, to="ordinal_num"), out)
|
||||||
@@ -1,4 +1,20 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
@@ -53,9 +69,6 @@ class Num2WordsLTTest(TestCase):
|
|||||||
'minus penki tūkstančiai kablelis dvidešimt du',
|
'minus penki tūkstančiai kablelis dvidešimt du',
|
||||||
)
|
)
|
||||||
|
|
||||||
# print(fill(n2w(1000000000000000000000000000000)))
|
|
||||||
# naintilijonas
|
|
||||||
|
|
||||||
def test_to_ordinal(self):
|
def test_to_ordinal(self):
|
||||||
# @TODO: implement to_ordinal
|
# @TODO: implement to_ordinal
|
||||||
with self.assertRaises(NotImplementedError):
|
with self.assertRaises(NotImplementedError):
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
@@ -48,9 +64,6 @@ class Num2WordsLVTest(TestCase):
|
|||||||
'mīnus pieci tūkstoši komats divdesmit divi',
|
'mīnus pieci tūkstoši komats divdesmit divi',
|
||||||
)
|
)
|
||||||
|
|
||||||
# >>> print(fill(n2w(1000000000000000000000000000000)))
|
|
||||||
# nontiljons
|
|
||||||
|
|
||||||
self.assertEqual(num2words(0, lang='lv'), 'nulle')
|
self.assertEqual(num2words(0, lang='lv'), 'nulle')
|
||||||
self.assertEqual(num2words(5, lang='lv'), "pieci")
|
self.assertEqual(num2words(5, lang='lv'), "pieci")
|
||||||
self.assertEqual(num2words(15, lang='lv'), "piecpadsmit")
|
self.assertEqual(num2words(15, lang='lv'), "piecpadsmit")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -45,6 +46,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 "
|
||||||
@@ -52,7 +57,7 @@ class Num2WordsPLTest(TestCase):
|
|||||||
"dziewięćdzisiąt dwa tryliardy trzydzieści dziewięć trylionów "
|
"dziewięćdzisiąt dwa tryliardy trzydzieści dziewięć trylionów "
|
||||||
"dwa biliardy sto pięćdziesiąt siedem bilionów sto osiemdziesiąt "
|
"dwa biliardy sto pięćdziesiąt siedem bilionów sto osiemdziesiąt "
|
||||||
"dziewięć miliardów osiemset osiemdziesiąt trzy miliony "
|
"dziewięć miliardów osiemset osiemdziesiąt trzy miliony "
|
||||||
"dziewęćset jeden tysięcy sześćset siedemdziesiąt sześć"
|
"dziewięćset jeden tysięcy sześćset siedemdziesiąt sześć"
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
num2words(719094234693663034822824384220291, lang='pl'),
|
num2words(719094234693663034822824384220291, lang='pl'),
|
||||||
@@ -64,6 +69,18 @@ class Num2WordsPLTest(TestCase):
|
|||||||
"osiemdziesiąt cztery miliony dwieście dwadzieścia "
|
"osiemdziesiąt cztery miliony dwieście dwadzieścia "
|
||||||
"tysięcy dwieście dziewięćdzisiąt jeden"
|
"tysięcy dwieście dziewięćdzisiąt jeden"
|
||||||
)
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
num2words(
|
||||||
|
963301000001918264129471001047146102 * 10**30 + 1007,
|
||||||
|
lang='pl'
|
||||||
|
),
|
||||||
|
"dziewięćset sześćdziesiąt trzy decyliardy trzysta jeden "
|
||||||
|
"decylionów nonylion dziewięćset osiemnaście oktyliardów dwieście "
|
||||||
|
"sześćdziesiąt cztery oktyliony sto dwadzieścia dziewięć "
|
||||||
|
"septyliardów czterysta siedemdziesiąt jeden septylionów "
|
||||||
|
"sekstyliard czterdzieści siedem sekstylionów sto czterdzieści "
|
||||||
|
"sześć kwintyliardów sto dwa kwintyliony tysiąc siedem"
|
||||||
|
)
|
||||||
|
|
||||||
def test_to_ordinal(self):
|
def test_to_ordinal(self):
|
||||||
# @TODO: implement to_ordinal
|
# @TODO: implement to_ordinal
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
243
tests/test_sr.py
Normal file
243
tests/test_sr.py
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from num2words import num2words
|
||||||
|
|
||||||
|
|
||||||
|
class Num2WordsSRTest(TestCase):
|
||||||
|
|
||||||
|
def test_cardinal(self):
|
||||||
|
self.assertEqual("sto", num2words(100, lang='sr'))
|
||||||
|
self.assertEqual("sto jedan", num2words(101, lang='sr'))
|
||||||
|
self.assertEqual("sto deset", num2words(110, lang='sr'))
|
||||||
|
self.assertEqual("sto petnaest", num2words(115, lang='sr'))
|
||||||
|
self.assertEqual(
|
||||||
|
"sto dvadeset tri", num2words(123, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"jedna hiljada", num2words(1000, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"jedna hiljada jedan", num2words(1001, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"dve hiljade dvanaest", num2words(2012, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"dvanaest hiljada petsto devetnaest zapeta osamdeset pet",
|
||||||
|
num2words(12519.85, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"jedan bilion dvesta trideset četiri miliona petsto "
|
||||||
|
"šezdeset sedam hiljada osamsto devedeset",
|
||||||
|
num2words(1234567890, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"dvesta petnaest noniliona četristo šezdeset jedan "
|
||||||
|
"oktilion četristo sedam septiliona osamsto devedeset "
|
||||||
|
"dva sekstiliona trideset devet kvintiliona dva kvadriliona "
|
||||||
|
"sto pedeset sedam triliona sto osamdeset devet biliona "
|
||||||
|
"osamsto osamdeset tri miliona devetsto jedna hiljada "
|
||||||
|
"šesto sedamdeset šest",
|
||||||
|
num2words(215461407892039002157189883901676, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"sedamsto devetnaest noniliona devedeset četiri oktiliona "
|
||||||
|
"dvesta trideset četiri septiliona šesto devedeset tri "
|
||||||
|
"sekstiliona šesto šezdeset tri kvintiliona trideset "
|
||||||
|
"četiri kvadriliona osamsto dvadeset dva triliona osamsto "
|
||||||
|
"dvadeset četiri biliona trista osamdeset četiri miliona "
|
||||||
|
"dvesta dvadeset hiljada dvesta devedeset jedan",
|
||||||
|
num2words(719094234693663034822824384220291, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual("pet", num2words(5, lang='sr'))
|
||||||
|
self.assertEqual("petnaest", num2words(15, lang='sr'))
|
||||||
|
self.assertEqual("sto pedeset četiri", num2words(154, lang='sr'))
|
||||||
|
self.assertEqual(
|
||||||
|
"jedna hiljada sto trideset pet",
|
||||||
|
num2words(1135, lang='sr')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"četristo osamnaest hiljada petsto trideset jedan",
|
||||||
|
num2words(418531, lang='sr'),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"jedan milion sto trideset devet",
|
||||||
|
num2words(1000139, lang='sr')
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_floating_point(self):
|
||||||
|
self.assertEqual("pet zapeta dva", num2words(5.2, lang='sr'))
|
||||||
|
self.assertEqual(
|
||||||
|
"petsto šezdeset jedan zapeta četrdeset dva",
|
||||||
|
num2words(561.42, lang='sr')
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_to_ordinal(self):
|
||||||
|
# @TODO: implement to_ordinal
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
num2words(1, lang='sr', to='ordinal')
|
||||||
|
|
||||||
|
def test_to_currency(self):
|
||||||
|
self.assertEqual(
|
||||||
|
'jedan evro, nula centi',
|
||||||
|
num2words(1.0, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dva evra, nula centi',
|
||||||
|
num2words(2.0, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'pet evra, nula centi',
|
||||||
|
num2words(5.0, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dva evra, jedan cent',
|
||||||
|
num2words(2.01, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
'dva evra, dva centa',
|
||||||
|
num2words(2.02, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dva evra, pet centi',
|
||||||
|
num2words(2.05, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dve rublje, nula kopejki',
|
||||||
|
num2words(2.0, lang='sr', to='currency', currency='RUB')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dve rublje, jedna kopejka',
|
||||||
|
num2words(2.01, lang='sr', to='currency', currency='RUB')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dve rublje, dve kopejke',
|
||||||
|
num2words(2.02, lang='sr', to='currency', currency='RUB')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dve rublje, pet kopejki',
|
||||||
|
num2words(2.05, lang='sr', to='currency', currency='RUB')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'jedan dinar, nula para',
|
||||||
|
num2words(1.0, lang='sr', to='currency', currency='RSD')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dva dinara, dve pare',
|
||||||
|
num2words(2.02, lang='sr', to='currency', currency='RSD')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'pet dinara, pet para',
|
||||||
|
num2words(5.05, lang='sr', to='currency', currency='RSD')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'jedanaest dinara, jedanaest para',
|
||||||
|
num2words(11.11, lang='sr', to='currency', currency='RSD')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dvadeset jedan dinar, dvadeset jedna para',
|
||||||
|
num2words(21.21, lang='sr', to='currency', currency='RSD')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dvadeset jedan evro, dvadeset jedan cent',
|
||||||
|
num2words(21.21, lang='sr', to='currency', currency='EUR')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'dvadeset jedna rublja, dvadeset jedna kopejka',
|
||||||
|
num2words(21.21, lang='sr', to='currency', currency='RUB')
|
||||||
|
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'jedna hiljada dvesta trideset četiri evra, '
|
||||||
|
'pedeset šest centi',
|
||||||
|
num2words(
|
||||||
|
1234.56, lang='sr', to='currency', currency='EUR'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'jedna hiljada dvesta trideset četiri rublje, '
|
||||||
|
'pedeset šest kopejki',
|
||||||
|
num2words(
|
||||||
|
1234.56, lang='sr', to='currency', currency='RUB'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'sto jedan evro i jedanaest centi',
|
||||||
|
num2words(
|
||||||
|
10111,
|
||||||
|
lang='sr',
|
||||||
|
to='currency',
|
||||||
|
currency='EUR',
|
||||||
|
seperator=' i'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'sto jedna rublja i dvadeset jedna kopejka',
|
||||||
|
num2words(
|
||||||
|
10121,
|
||||||
|
lang='sr',
|
||||||
|
to='currency',
|
||||||
|
currency='RUB',
|
||||||
|
seperator=' i'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'sto jedna rublja i dvadeset dve kopejke',
|
||||||
|
num2words(10122, lang='sr', to='currency', currency='RUB',
|
||||||
|
seperator=' i')
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'sto jedan evro i dvadeset jedan cent',
|
||||||
|
num2words(10121, lang='sr', to='currency', currency='EUR',
|
||||||
|
seperator=' i'),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'minus dvanaest hiljada petsto devetnaest evra, 85 centi',
|
||||||
|
num2words(
|
||||||
|
-1251985,
|
||||||
|
lang='sr',
|
||||||
|
to='currency',
|
||||||
|
currency='EUR',
|
||||||
|
cents=False
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
"trideset osam evra i 40 centi",
|
||||||
|
num2words('38.4', lang='sr', to='currency', seperator=' i',
|
||||||
|
cents=False, currency='EUR'),
|
||||||
|
)
|
||||||
@@ -1,4 +1,19 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
# Copyright (c) 2017, Tufan Kaynak, Framras. All Rights Reserved.
|
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
# License along with this library; if not, write to the Free Software
|
# License along with this library; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
# MA 02110-1301 USA
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
|
# This library is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
# License as published by the Free Software Foundation; either
|
||||||
|
# version 2.1 of the License, or (at your option) any later version.
|
||||||
|
# This library is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# Lesser General Public License for more details.
|
||||||
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
|
# License along with this library; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from num2words.utils import splitbyx
|
from num2words.utils import splitbyx
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2015, Savoir-faire Linux inc. All Rights Reserved.
|
# Copyright (c) 2003, Taro Ogawa. All Rights Reserved.
|
||||||
|
# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved.
|
||||||
|
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public
|
# modify it under the terms of the GNU Lesser General Public
|
||||||
|
|||||||
Reference in New Issue
Block a user