Coder Social home page Coder Social logo

num2words's Issues

"one hundred, ninety-eight" vs. "one hundred ninety-nine" vs. "one hundred and ninety-eight"

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.

0.5.4 installation is failing

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

Support Python 2.5

Please add support to in Python 2.5, i have a old system to use it. I get this error:

In [12]: import num2words

SyntaxError: future feature unicode_literals is not defined (lang_EN.py, line 17)

Include license files in the pypi tarball

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

Implement Norwegian language support

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?

how to use to_year() functions

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?

Ein vs. Eins in German

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.

Added TR translation

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.

unicode problem with python2.7, lang="de"

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)

u before result

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'

floating point?

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'

Vietnam lang conversion is wrong !

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 !

Wrong float interpretation

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 with cents false seem to be broken

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.

Py3.3 canot run

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

Bugs in tanslation from 30 to 40 in spanish

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

Installation on windows server

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

french ordinals

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!

Missing negative cases in PL language

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 :)

issue after converting number to words

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.