Locale support for dates and times

23 Oct 2017 context, duckling

Today, we are adding locale support to improve detection and resolving of date and time expressions.

Context is key in NLP. This is especially true when trying to understand dates or locations. For instance, “today” will be interpreted as differently depending on the timezone of the user: the same absolute time may be the 17th in San Francisco and the 18th in Hong-Kong.

You can already pass reference_time or timezone as context to help resolve dates and times. Starting today you can also provide a locale.

Depending on what country your user is from, the same sentence may mean different things. “remind me on 11/12” means Nov 12th in the US but Dec 11th for our mates in the UK! Similarly, “Thanksgiving 2017” means November 23rd in the US, while it means October 9th to a Canadian.

If the user locale is supported by Duckling, our open-source linguistic parser, Wit will use it to deliver the correct result for your user. If a locale is not yet available in Duckling, it will default to the “parent” language with no locale-specific customizations. We welcome contributions from the community to help us improve our coverage of various locales. Head over to our GitHub repository to contribute!

Here is an example of calling Wit passing the “en_GB” locale:

curl \
-H 'Authorization: Bearer $WIT_ACCESS_TOKEN' \
'https://api.wit.ai/message?v=20171018&q=remind%20me%20on%2011%2F12&context=%7B%22locale%22%3A%22en_GB%22%7D'

{"msg_id":"0Wo02v2lMNlNtmSQW","_text":"remind me on 11\/12","entities":{"datetime":[{"confidence":0.9668475,"values":[{"value":"2017-12-11T00:00:00.000-08:00","grain":"day","type":"value"},{"value":"2018-12-11T00:00:00.000-08:00","grain":"day","type":"value"},{"value":"2019-12-11T00:00:00.000-08:00","grain":"day","type":"value"}],"value":"2017-12-11T00:00:00.000-08:00","grain":"day","type":"value"}]}}

As always, feel free to reach out if you have any questions, comments, or suggestions!

Team Wit