Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duckling Plugin filters Time_entity whose Time_entity.value.hour == reftime.hour if datetime_filters is set. #133

Open
keshav47 opened this issue Mar 21, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@keshav47
Copy link
Contributor

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:

  1. Set one of the alternatives as "5pm"
  2. put reference_time in context anything between [17:00:01, 17:59:59]
  3. 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.

@keshav47 keshav47 added the bug Something isn't working label Mar 21, 2022
@keshav47 keshav47 linked a pull request Mar 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants