savoirfairelinux / num2words Goto Github PK
View Code? Open in Web Editor NEWModules to convert numbers to words. 42 --> forty-two
License: GNU Lesser General Public License v2.1
Modules to convert numbers to words. 42 --> forty-two
License: GNU Lesser General Public License v2.1
Hi
The version in https://pypi.python.org/pypi/num2words seems outdated. If install with pip
when the program try to use the pt_BR, I got this error
from num2words.lang_PT_BR import Num2Word_PT_BR
ImportError: No module named lang_PT_BR
But if I clone this repo and install works fine.
The test coverage for the num2words/lang_EN.py file is 57.81% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_ES.py file is 73.03% and we need to increment this to at least 90%.
Comparing the outputs of Taro Ogawa's original library (namely num2word_EN.to_card) and yours, I found some recurring discrepancies:
one hundred and ninety-eight
one hundred, ninety-eight (the "and" is replaced by a comma)
one hundred and ninety-nine
one hundred ninety-nine (the "and" is suppressed)
two hundred and ninety-eight
two hundred, ninety-eight
two hundred and ninety-nine
two hundred, ninety-nine
...
Taro Ogawa's gives the expected result (21124) on the 17th problem of the Projet Euler: http://projecteuler.net/problem=17. Yours give 21070. Using lang="en"
or lang="en_GB"
makes no difference.
root@avi-dev:/tmp/tt# /tmp/tt/bin/pip install num2words
Downloading/unpacking num2words
Downloading num2words-0.5.4-py2-none-any.whl (94kB): 94kB downloaded
Installing collected packages: num2words
Cleaning up...
num2words is in an unsupported or invalid wheel
Storing debug log for failure in /root/.pip/pip.log
Please add support to in Python 2.5, i have a old system to use it. I get this error:
SyntaxError: future feature unicode_literals is not defined (lang_EN.py, line 17)
The test coverage for the num2words/lang_RU.py file is 66.3% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_UK.py file is 54.35% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_SL.py file is 71.26% and we need to increment this to at least 90%
The test coverage for the num2words/lang_EN_GB.py file is 57.89% and we need to increment this to at least 90%.
Hi
I am packaging num2words in Fedora, I see you are using the GPL license but you do not include the license file in the pypi tarball, can you please add the sile so I have not to patch your app at the moment of create the rpm
Hi, I have started translating the german version into norwegian, but not entirely sure what everything is and what to translate. Is there a language guide I could follow?
I see in code there are calls to to_year() function, example:
print(n2w.to_year(2001))
in Num2Word_DE class. What's the right way to access this function?
The test coverage for the num2words/lang_DK.py file is 30.77% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_AR.py file is 75.0% and we need to increment this to at least 90%.
Hi,
Currently num2words(1, lang='de') gives "eins" which is correct in certain contexts (e.g. if one refers to the digit one or "Page 1" --> "Seite Eins") but wrong in other cases (if it is followed by a noun, e.g. "1 Meter'" => Ein Meter", "Eins Meter" would be wrong). I'm not sure how this can be handled properly, maybe by an additional flag so that the user can decide weather "eins" or "ein" should be returned? If this is to much work I would suggest changing it to "ein", because from my feeling this variant is used more often. But of course this depends on the context, maybe other German speaker can comment on this as well.
Hi, it would be fine to be able to exclude "and" in the text produced. Would that be possible to add?
Thanks.
I have uploaded file for TR translation. File name is lang_TR.py
I recently startep using ERPNEXT and I need the Turkish translation for numbers.
Test file test_tr.py to follow.
The test coverage for the num2words/lang_ES_CO.py file is 55.56% and we need to increment this to at least 90%.
Hello, thanks for this module!
I came across a unicode problem. You can see this works with python3:
$ python3 -c "import num2words; print(num2words.num2words(0.5, lang='de'))"
null Komma fünf null
but fails with python 2.7:
$ python2.7 -c "import num2words; print(num2words.num2words(0.5, lang='de'))"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/num2words/__init__.py", line 50, in num2words
return converter.to_cardinal(number)
File "/usr/local/lib/python2.7/site-packages/num2words/base.py", line 93, in to_cardinal
return self.to_cardinal_float(value)
File "/usr/local/lib/python2.7/site-packages/num2words/base.py", line 127, in to_cardinal_float
out.append(str(self.to_cardinal(curr)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)
The problem being the call to str()
which in python3 returns a unicode string, but in 2.7 str()
can only return ASCII bytes. (In 2.7 unicode()
would need to be called instead of str()
to get a unicode string)
The test coverage for the num2words/lang_HE.py file is 27.27% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_ES_VE.py file is 55.56% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_NO.py file is 43.08% and we need to increment this to at least 90%.
when using num2word(1000000, lang='lt') it converts to "vienas milijonas tūkstančių" (one milion thousands) also same behavior in lv conversion.
Hi,
Alway shows the 'u' vowel at the start of each result, is it normal?
num2words(111999, lang='es')
u'ciento once mil novecientos noventa y nueve'
Doesn't seem to support floating point well.
>>> num2words(111.3)
u'one hundred and eleven point two nine'
>>> num2words(.1234)
u'zero point one two'
in Vietnam lang :
145001000 read correctly is : "một trăm bốn lăm triệu không trăm lẻ một ngàn"
you can fix it :)
+> test case wrong :
self.assertEqual(num2words(523056, lang="vi_VN"), "năm trăm hai mươi ba nghìn năm mươi sáu")
+> fix right : self.assertEqual(num2words(523056, lang="vi_VN"), "năm trăm hai mươi ba nghìn không trăm năm mươi sáu")
P/S : sorry my english is bad !
I'm running the example as:
num2words(11)
u'eleven'
And then:
num2words(11.10)
u'eleven point zero nine'
Somehow there is a rounding somewhere doing it wrong.
to_currency
form that takes currency
as argument with cents=False
seem to produce unexpected results when there is not enough precision available.
For instance num2words(Decimal('38.4'), lang='lv', to='currency', seperator=' un', cents=False, currency='EUR)
results in Trīsdesmit astoņi euro un 04 centi
.
Is this expected behaviour? All converters that support this form seem to be affected.
left, right = n.split('.')
seems to be too naive for right part since it doesn't respect position.
The test coverage for the num2words/lang_FR.py file is 73.44% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_DE.py file is 73.17% and we need to increment this to at least 90%.
Py3.3 embedded, for editor like Sublime text (so I cannot use Py3.4), cannot run. Err on importing num2words.
File "num2words\lang_EN.py", line 50
def merge(self, (ltext, lnum), (rtext, rnum)):
SyntaxError: invalid syntax
In [23]: for n in range(29, 41):
print num2words.num2words(n, lang='es')
....:
vientinueve
vientinueve y uno
vientinueve y dos
vientinueve y tres
vientinueve y cuatro
vientinueve y cinco
vientinueve y seis
vientinueve y siete
vientinueve y ocho
vientinueve y nueve
vientinueve y diez
cuarenta
The test coverage for the num2words/lang_NL.py file is 75.0% and we need to increment this to at least 90%.
Hi,
We installed num2word on a windows server but the module l10n_ca_account_check_writing doesn't find it. Is there a special install for windows server? or special code modification?
Thanks
Hi. Is there a possibility to add grammatical case argument?
Thanks.
Hello again!
from num2words import num2words
print num2words(5, lang="fr", ordinal=True)
print num2words(9, lang="fr", ordinal=True)
produces:
cinqième
neufième
Expected result:
cinquième
neuvième
Source: I am French.
Thanks!
The test coverage for the num2words/lang_LT.py file is 22.09% and we need to increment this to at least 90%.
The test coverage for the num2words/lang_LV.py file is 23.26% and we need to increment this to at least 90%.
int2word function is missing case when value is negative -> returning exception
ValueError: invalid literal for int() with base 10: '-'
Proposal fix:
if n < 0: return ' '.join([u'minus', int2word(abs(n))])
This is the same as for RU language except Polish word :)
Hi
Just a question, python-num2words is placing tests files under the root directory of python site-packages, I can not include this files in the rpm, I will exclude this files but It could be nice to move remane the tests directory to num2words-test or something similar so I will can include this files in furete versions of the package.
The test coverage for the num2words/lang_FR_DZ.py file is 65.0% and we need to increment this to at least 90%.
Please change or adjust the description:
Is there any option to use num2words with currency?
In Spanish, the library outputs "Ciento mil" for the number 100000. The output should be "Cien mil"
Is anyone doing Danish language support?
Hi,
Thanks for your lib that helps me so much to convert number to words. But, I have some following issues:
num2words(12.50, ordinal=False, lang='en')
u'twelve point five zero'num2words(12.51, ordinal=False, lang='en')
u'twelve point five zero'
num2words(12.52, ordinal=False, lang='en')
u'twelve point five one'
num2words(12.53, ordinal=False, lang='en')
u'twelve point five two'
num2words(12.54, ordinal=False, lang='en')
u'twelve point five three'num2words(12.55, ordinal=False, lang='en')
u'twelve point five five'
num2words(12.56, ordinal=False, lang='en')
u'twelve point five six'
num2words(12.57, ordinal=False, lang='en')
u'twelve point five seven'
num2words(12.58, ordinal=False, lang='en')
u'twelve point five eight'num2words(12.59, ordinal=False, lang='en')
u'twelve point five eight'
Can you help me to tackle them?
Thanks a lot!
Best regards,
Tien
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.