allo-media / text2num

Parse and convert numbers written in French, English, Spanish, Portuguese, German and Catalan into their digit representation.
https://text2num.readthedocs.io
MIT License
102 stars 47 forks source link

Separate digits #91

Closed Kuaranir closed 1 year ago

Kuaranir commented 1 year ago

Doesn't work with separate digits like: from text_to_num import text2num print(text2num("eight nine two", "en")) Output: ValueError: invalid literal for text2num: 'eight nine two' Desired: 892 or 8 9 2 maybe

fungus75 commented 1 year ago

In that case I would suggest to split up at blanks and convert each "word" itself and join it to one string after that. Would that be a solution?

rtxm commented 1 year ago

text2num it for converting an expression into an integer. The expression "eight nine two" is not a valid integer.

If you you want to transform the input into the string "8 9 2", you should use the alpha2digit function instead.

Kuaranir commented 1 year ago

alpha2digit

thanks, it works