nielstron / quantulum3

Library for unit extraction - fork of quantulum for python3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: how to support a comma-separated number, e.g. 589,2MT/year?

renaud opened this issue · comments

Sorry I could not find that in the documentation... Did I miss something?

BTW, really cool project! Kudos!

currently the decimal separator is handled as part of the language settings (https://github.com/nielstron/quantulum3/blob/dev/quantulum3/_lang/en_US/regex.py in DECIMAL_SEPARATOR)

If this is uncorrectly assuming that "." is the normal decimal separator in the English language please say so. Otherwise someone would need to implement a new language support for "," as decimal Operator. (This assumes that the surrounding text will be in the different language as well which could screw the disambiguation if the language setting is not changed)

right, thanks @nielstron . In the meantime, as a hacky workaround, I just fix it this way...

# fix decimal point, else quantulum3 doesn't recognizes it...
txt = re.sub(r'(\d),(\d)', r'\1.\2', txt)