MycroftAI / lingua-franca

Mycroft's multilingual text parsing and formatting library
Apache License 2.0
73 stars 77 forks source link

Wrong interpretation as fractions #205

Closed Nithin-Holla closed 2 years ago

Nithin-Holla commented 2 years ago

Describe the bug For inputs such as 'eighteenthandtwentieth` as in centuries, the input is wrongly interpreted as fractions and the output is a decimal number for instance 0.05555 (1/18) and 0.05 (1/20) respectively. This is incorrect.

To Reproduce Steps to reproduce the behavior:

import lingua_franca
from lingua_franca.parse import extract_number
lingua_franca.load_language('en')
print(extract_number('eighteenth'))
print(extract_number('twentieth'))

Expected behavior The output could be False if it can't be converted to 18th and 20th for example.

Environment (please complete the following information):

krisgesling commented 2 years ago

Hi Nithin,

If you use the ordinals argument, this will return the correct number. Try this:

print(extract_number('eighteenth', ordinals=True))
print(extract_number('twentieth', ordinals=True))

Would that meet your needs?

Nithin-Holla commented 2 years ago

Ah, wasn't aware of this argument. It's fine then!