w2n
w2n copied to clipboard
Error on parsing "one half"
>>> from word2number import w2n
>>> w2n.word_to_num("one and one half")
2
Expected output: 1.5
Thanks for pointing this out. I will look into this ASAP. Meanwhile, you're also welcome to fix the error and submit a Pull Request. If it passes all the tests, it will be merged most probably.
Similar: #30
Am I correct in thinking that words for fractions (half, third, three quarters etc) are not addressed at all currently ?
It has to do with the way Python rounds numbers. It doesn't always round in the way you would expect, or in this case, rounds by default.
Am I correct in thinking that words for fractions (half, third, three quarters etc) are not addressed at all currently ?
Yes as you can see in the source code, "half", "third" or similar words are never mentioned and hence the corresponding strings also never parsed. This is also why @bobbint there never is any rounding of "half". On the other hand "zero point five" would be correctly parsed as "0.5"