Inconsistent duckling date extraction involving relative dates

I am currently using duckling in my Rasa application to help me extract dates from user inputs. However, I recently ran into an issue with the date extraction and am unsure on how to fix the issue or why the issue occurs.

The Issue: Duckling incorrectly parses relative dates with positional key words like “last” or “this” by a very large margin.

Example:

Let’s say the date is Tuesday, October 6th, 2020 PDT.

If the text is “What is the date 22 weeks from this friday”, Duckling returns 2021-03-12T00:00:00.000-08:00 which is correct.

If the text is “What is the date 22 weeks from friday”, Duckling returns 2020-12-18T00:00:00.000-08:00, which is incorrect. Counting back, it looks like Duckling used July 17th, 2020 as the starting point.

Similarly, if the text is “what is the date 10 years from friday”, Duckling returns 2030-07-17T00:00:00.000-07:00 which is incorrect. We can see that here, Duckling used July 17th, 2020 as a starting point again.

My question is, what is the significance of July 17th? Why is it the date used when key words such as “this”, “last” and “next” are not used in conjunction with Friday? And how can I go about this issue? Any insight is appreciated.

This bug can be replicated on my local docker-compose setup, on the AWS cloud, and when I spin up Duckling as a standalone container locally and send a request to it. The grains that Duckling sends back are also way off the mark.

OS: MacOS

Rasa: 2.0.0a4

Python: 3.7.7

Duckling image: rasa/duckling:0.1.6.3 (latest)

If you want to try it out, you can run a duckling container locally and send a cURL request to it like this:

docker run -p 8000:8000 rasa/duckling
curl -XPOST http://0.0.0.0:8000/parse --data 'text=22 weeks from friday'
curl -XPOST http://0.0.0.0:8000/parse --data 'text=22 weeks from this friday'

Hi @jkuan, is this something that also happens when you run duckling directly from facebook? Our image is branched off of theirs, so if that is the case, you should bring up in the duckling repository.

Apologies for the late reply.

I have only tried the playground feature on their website here which was not very helpful.

I will take a look when running duckling directly from its github repository. I also see that the latest rasa/duckling image was released 5 days ago so I will try out that version as well.

hi @jkuan ,

I don’t know if you fixed this issue or not, but I struggled with the same. What you can do is if you call duckling you can give a timezone and reftime parameter from your location. “locale”:“en_US”, “reftime”: timestamp, “tz”: “UTC”

where timestamp is: now = datetime.now() timestamp = datetime.timestamp(now)

Hope this helps.

hi @erohmensing - I don’t know however if I would setup duckling in the config file, what is the behavior? Will rasa always pass the current time to duckling each call? If not, maybe this can be a good feature to add. Once user will declare the tz in the config file, you know the timezone of the user, so at every duckling call you can calculate the reftime and pass it along with the rest of the parameters. I think this would solve the original problem.