nielstron / quantulum3

Library for unit extraction - fork of quantulum for python3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Perplexing results from "<qty> and a half <unit>"

jrd-nonlilly opened this issue · comments

Describe the bug
The parsing of <qty> and a half <unit> seems broken.

I don't know whether this is a bug or a feature request, because I'm still trying to trace through the code to understand the logic.

To Reproduce
Steps to reproduce the behavior:

  1. Invoke parser.parse("two and a half months") (using en_US)
  2. See result: (1.5, 'month')
  3. Scratch head

Expected behavior
I expect (2.5, 'month'). Similarly, "five and a half months" gives (3.0, 'month').

Additional information:

  • Python Version: 3.8
  • Classifier activated/ sklearn installed: no?
  • OS: macOS
  • Version 10.15.7

It should have been obvious, but upon further reflection there must be logic somewhere that interprets "half" as both "divide this quantity in half" and "add half this quantity", applied in that order.

Thanks for the note! I found the bug and fixed it in the dev branch of this project :)