I have a Luis model created for a bot skill. I'm using the prebuilt datetime
entity for dates.
When I give sample utterance such as "Sell 5k [jargon] for this weekend at [jargon]" on the Luis portal's test tool, I get the response I expect (shown below). The timex is 2020-W02-WE
and resolves to 1/11 - 1/13.
Note that for the example below, I used "this weekend" as the query, but it resolves the same regardless of whether I enter an utterance that matches my skill intent. "this weekend" was used for simplicity in the example.
Expected:
{
"query": "this weekend",
"prediction": {
"normalizedQuery": "this weekend",
"topIntent": "None",
"intents": {
"None": {
"score": 0.8771556
}
},
"entities": {
"datetimeV2": [
{
"type": "daterange",
"values": [
{
"timex": "2020-W02-WE",
"start": "2020-01-11", *** Saturday ***
"end": "2020-01-13" *** Monday ***
}
]
}
],
"$instance": {
"datetimeV2": [
{
"type": "builtin.datetimeV2.daterange",
"text": "this weekend",
"startIndex": 0,
"length": 12,
"modelTypeId": 2,
"modelType": "Prebuilt Entity Extractor",
"recognitionSources": [
"model"
]
}
]
}
}
}
}
The problem is that when I use the same utterance locally, I'm getting a date range representing the whole week 1/6/2020 - 1/13/2020 (Monday - Monday). The Timex is the same; however, when I resolve it, I'm getting a different value.
Luis Response to Emulator using utterance "this weekend":
{
"recognizerResult": {
"alteredText": null,
"entities": {
"$instance": {
"datetime": [
{
"endIndex": 12,
"startIndex": 0,
"text": "this weekend",
"type": "builtin.datetimeV2.daterange"
}
]
},
"datetime": [
{
"timex": [
"2020-W02-WE"
],
"type": "daterange"
}
]
},
"intents": {
"None": {
"score": 0.8771556
}
},
"text": "this weekend"
}
}
// 2020-W01-WE - This should resolve to weekend; doesn't work locally, works on Luis.
Resolution resolution =
TimexResolver.Resolve(((List<string>)options.Entities.datetime[0].Expressions).ToArray());
var start = resolution.Values?[0].Start; // 01/06/2020
var end = resolution.Values?[0].End; // 01/13/2020
Any ideas on what I'm doing wrong with how I'm resolving it?
You're right, this looks like it certainly should work. I think it's a bug in the TimexResolver, so I've written a unit test and submitted a PR to the team - you can see it here (ironically it's PR "2020").
If you need this fix super urgently, you can pull my copy of TimexResolver into your own project, and rename it (e.g. TimexResolve2) while we wait for the PR to be reviewed and hopefully accepted.
[Update] The PR was already been accepted and merged into master (that was quick!). You can see it here - now we just need to wait for the next release of Recognizers-Text, or just download/clone the project locally for now, an watch for releases on GH