Chatterbot: Datetime parsing does not recognize am/pm

Created on 23 Apr 2018  路  3Comments  路  Source: gunthercox/ChatterBot

I can say datetime parser is much better than any other parser, However I am facing issue of parsing a datetime with am/pm information. e.g.

text= u'Your dental appointment with Dr P. Delvour is scheduled for October 29, 4:00pm. ABC Dentist, 555-555-555.'
dates_ch = parsing.datetime_parsing(text, base_date=datetime.datetime(2018, 4, 23, 21, 16, 50, 511608))
Output: [('October 29, 4:00', datetime.datetime(2018, 10, 29, 4, 0), (60, 76))]

I was though expecting

[('October 29, 4:00pm', datetime.datetime(2018, 10, 29, 16, 0), (60, 76))]

I am taking look at the parsing.py class. Being new to python, I would appreciate to know which regex to be modified?

enhancement

All 3 comments

IMHO: Please all python related question into stackoverflow or google groups you may good response. This issue tracker field used to track all chatterbot framework/logic/error reporter tracker.

For you question this might the answer https://stackoverflow.com/a/1759485/358458

Hello vkosuri, this is though a python question but its about regex re_time at line no 28 of parsing.py. I dont have any problem to change it as per my need. But as this is a genuine issue so it should be reflected in parsing.py which I dont have access. I am using chatterbot api to parse texts

from chatterbot import parsing
dates_ch = parsing.datetime_parsing(text, base_date=datetime.datetime(2018, 4, 23, 21, 16, 50, 511608))

and how do you suggest me to override re_time and still use the this api.

Thanks, re_time expecting am|pm somehow doesn't considering i will look into this issue.

https://github.com/gunthercox/ChatterBot/blob/eab5bb43f0a73fcb49870762f0ffcf74f26d86de/chatterbot/parsing.py#L32

Was this page helpful?
0 / 5 - 0 ratings