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

German: Numbers are falsely being added up #100

Closed qp450 closed 11 months ago

qp450 commented 12 months ago

Thank you for this package, it's very useful!

I am using it for German and would like to report a bug: When inputting "vier fünfhundert", I expect "4 500", but get "504". This seems to be happening whenever there is a number from 1-99 followed by a hundred with a multiplier (einhundert-neunhundert), for example "dreizehn siebenhundert" -> "713" or "achtundachtzig sechshundert" -> "688" (expected would be "13 700" and "88 600"). I have identified that this behavior stems from the parse() function in the WordStreamValueParserGerman() class. The three parts (for example "vier", "fünf", "hundert") are added to a list, then "fünf" and "hundert" are resolved to "500", but then "vier" is still in the list and gets added to "500".

My python version is 3.10.12.

Would it be possible to fix this or do you have an idea where exactly or why this bug occurs? Thank you very much!