akshaynagpal / w2n

Convert number words (eg. twenty one) to numeric digits (21)
http://w2n.readthedocs.io
MIT License
165 stars 78 forks source link

Support "unicode" as well, use `basestring`, not `str`! #37

Open evandrix opened 5 years ago

evandrix commented 5 years ago
$ python -u code.py
Traceback (most recent call last):
  File "/code.py", line N, in <module>
    print w2n.word_to_num(ss)
  File "/usr/local/lib/python2.7/dist-packages/word2number/w2n.py", line 134, in word_to_num
    raise ValueError("Type of input is not string! Please enter a valid number word (eg. \'two million twenty three thousand and forty nine\')")
ValueError: Type of input is not string! Please enter a valid number word (eg. 'two million twenty three thousand and forty nine')

code.py: print>>sys.stderr, type(ss)

$ python -u code.py
<type 'unicode'> 
akshaynagpal commented 5 years ago

Thanks for pointing this out. I will look into this ASAP. Meanwhile, you're also welcome to fix the error and submit a Pull Request. If it passes all the tests, it will be merged most probably.