allo-media/text2num

[FR] french ordinals throwing errors

Closed this issue · 1 comments

Hi,

french ordinals throw errors although they are dealt with in the code, is there a mistake or am i doing something wrong?

thank you


ValueError Traceback (most recent call last)

in
----> 1 text2num("premier", "fr")

/usr/local/lib/python3.8/dist-packages/text_to_num/transforms.py in text2num(text, lang, relaxed)
85 tokens = list(dropwhile(lambda x: x in language.ZERO, text.split()))
86 if not all(num_parser.push(word, ahead) for word, ahead in look_ahead(tokens)):
---> 87 raise ValueError("invalid literal for text2num: {}".format(repr(text)))
88
89 return num_parser.value

ValueError: invalid literal for text2num: 'premier'

rtxm commented

text2num only convert valid intergers. Premier is not an integer.
What you want is alpha2digit:

>>> alpha2digit("premier", "fr", ordinal_threshold=0)
"1er"