[EN DateTimeV2] Resolution is None for text like "from around 1pm"
Describe the bug
resolution is None for text containing an unique combination of from and some time, some examples:
- "i am feeling sick from around 1pm"
- "I have pain and pressure in my lower abdomen, blurry vision and headache from around 2pm"
To Reproduce
from recognizers_date_time import DateTimeRecognizer; from recognizers_date_time import Culture; recognizer = DateTimeRecognizer(Culture.English); model = recognizer.get_datetime_model(); text = "I have pain and pressure in my lower abdomen, blurry vision and headache from around 2pm"; result = model.parse(text); for r in result: print(r.text, r.resolution, r.start, r.end, r.type_name)
Expected behavior if the text is "from around 2pm today" then resolution is correct, should have the same behavior in above case.
Sample input/output text = "I have pain and pressure in my lower abdomen, blurry vision and headache from around 2pm" resolution = None another_text = "i am feeling sick from around 1pm" resolution = None yet_another_text = "i will be back around 1am today" resolution = {'values': [{'timex': '2020-08-14T13', 'Mod': 'since', 'type': 'datetimerange', 'sourceEntity': 'datetimepoint', 'start': '2020-08-14 13:00:00'}]}
Platform (please complete the following information):
- Platform: Python
- Environment: Python REPL
- Version of package: 1.0.2a2
Additional context Add any other context about the problem here.
(.venv38) avinash@avinash-ThinkPad-E490:~/repos/MMC$ python Python 3.8.2 (default, Mar 21 2020, 16:51:37) [GCC 7.5.0] on linux Type "help", "copyright", "credits" or "license" for more information.
from recognizers_date_time import DateTimeRecognizer from recognizers_date_time import Culture recognizer = DateTimeRecognizer(Culture.English) model = recognizer.get_datetime_model() text = "I have pain and pressure in my lower abdomen, blurry vision and headache from around 2pm" result = model.parse(text) for r in result: ... print(r.text, r.resolution) ... around 2pm None for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... around 2pm None 78 87 datetimeV2.time another_text = "i will be back around 1 am today" result = model.parse(another_text) for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... around 1 am today {'values': [{'timex': '2020-08-14T01', 'type': 'datetime', 'value': '2020-08-14 01:00:00'}]} 15 31 datetimeV2.datetime yet_another_text = "i will be back around 1am today" result = model.parse(yet_another_text) for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... around 1am today {'values': [{'timex': '2020-08-14T01', 'type': 'datetime', 'value': '2020-08-14 01:00:00'}]} 15 30 datetimeV2.datetime yet_another_text = "i am feeling sick from 1pm today" result = model.parse(yet_another_text) for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... from 1pm today {'values': [{'timex': '2020-08-14T13', 'Mod': 'since', 'type': 'datetimerange', 'sourceEntity': 'datetimepoint', 'start': '2020-08-14 13:00:00'}]} 18 31 datetimeV2.datetimerange yet_another_text = "i am feeling sick from around 1pm today" result = model.parse(yet_another_text) for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... around 1pm today {'values': [{'timex': '2020-08-14T13', 'type': 'datetime', 'value': '2020-08-14 13:00:00'}]} 23 38 datetimeV2.datetime yet_another_text = "i am feeling sick from around 1pm" result = model.parse(yet_another_text) for r in result: ... print(r.text, r.resolution, r.start, r.end, r.type_name) ... around 1pm None 23 32 datetimeV2.time
@LionbridgeCSII can you take a look in .NET and estimate a fix?
@tellarin, the behaviour in .NET is different than the one described here: "i am feeling sick from around 1pm" -> "around 1pm" is extracted and resolved as Time "i am feeling sick from around 1pm today" -> "around 1pm today" is extracted and resolved as DateTime. I will try to make it extract "from around 1pm" as TimeRange instead.
Fixed first in .NET (#2252).