dialogy
dialogy copied to clipboard
Duckling Plugin filters Time_entity whose Time_entity.value.hour == reftime.hour if datetime_filters is set.
Describe the bug
Call reference_time: 21-03-22 17:24:34
(Turn 1) Bot: What day for booking? Person: tomorrow #Expected Entity: 22-03-22 00:00:00, Captured Entity:22-03-22 00:00:00 (Turn 2) Bot: What time? Person: Book it 5pm. #Expected Entity: 21-03-22 17:00:00, Captured Entity:""
Due to current logic here select_datetime(), when datetime_filters is set (either Past or Future), we filter out out 5pm entity if call is made between 17:00:01< reference time <17:59:59 on 21-03-22.
To Reproduce Steps to reproduce the behavior:
- Set one of the alternatives as "5pm"
- put reference_time in context anything between [17:00:01, 17:59:59]
- See error
Expected behavior Should get 5pm entity in turn 2. This can be sorted by doing comparison on hour and ignore time and seconds value completely.
reference_time = unix_ts_to_datetime(self.reference_time, timezone="Asia/Kolkata")
reference_time = reference_time.replace(
hour=reference_time.hour, minute=0, second=0, microsecond=0)
filtered_time_entities = [
entity
for entity in time_entities
if operation(dt2timestamp(entity.get_value()), dt2timestamp(reference_time))
]
Adding the following logic should solve this issue.