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

EntityRecognizer.resolveTime not resolving LUIS entities #1173

Closed
d3clan opened this issue Sep 5, 2016 · 4 comments
Closed

EntityRecognizer.resolveTime not resolving LUIS entities #1173

d3clan opened this issue Sep 5, 2016 · 4 comments
Assignees

Comments

@d3clan
Copy link

d3clan commented Sep 5, 2016

Bot Builder: v3.2.3
I'm having problems with the builder.EntityRecognizer.resolveTime(args.entities) resolving builtin.datetime.date coming back from LUIS.

After LUIS has resolved the enties, it returns for the string 'next summer':

{
  "entity": "next summer",
  "type": "builtin.datetime.date",
  "startIndex": 24,
  "endIndex": 34,
  "resolution": {
    "date": "2017-SU"
  }
}

This falls straight through the logic inside EntityRecognizer#resolveTime, returning undefined. I'm assuming this is regression due to a change in the data LUIS is returning?

I've had a look through the issues and found #7 logged back in March, but it's for a different problem.

I'm calling it in the same way as many of the examples:

var departureDate = builder.EntityRecognizer.resolveTime(args.entities);

Similarly, this will also fail given a more straightforward string of:

{
  "entity": "july 2017",
  "type": "builtin.datetime.date",
  "startIndex": 0,
  "endIndex": 8,
  "resolution": {
    "date": "2017-07"
  }
}

I'm pretty new to the Bot Framework, so please accept my apologies if I've missed something.

@willportnoy
Copy link
Member

Yes, it’s an issue. It would be useful to have code to parse the full extent of the “machine readable” LUIS entity resolutions in both the Node and C# SDKs.

We haven’t had the bandwidth to add complete parsing/interpretation to the Bot Builder SDK, and the LUIS client SDKs (https://github.com/Microsoft/Cognitive-LUIS-Windows/) do not appear to have support for parsing/interpreting these entity resolutions.

They can be quite complicated - for example “set an alarm for the morning of the second week of september in 2018”:
https://api.projectoxford.ai/luis/v1/application?id=c413b2ef-382c-45bd-8ff0-f76d60e2a821&subscription-key=752a2d86f21e47879c8e3ae88ca4c009&q=set%20an%20alarm%20for%20the%20morning%20of%20the%20second%20week%20of%20september%20in%202018

produces “TMO”, “XXXX-09-W02”, and “2018” as separate entities. I made an attempt to parse/interpret these resolutions in the C# SDK:
https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/LuisResolutionTests.cs#L66

and didn’t even realize “summer” was part of the format (there’s some documentation available at https://www.luis.ai/Help/#PreBuiltEntities).

@d3clan
Copy link
Author

d3clan commented Sep 8, 2016

Thanks for coming back to me.

I totally understand that you don’t have the bandwidth to deliver all functionality. Although we were a little surprised this hadn’t yet been implemented at all. A comment somewhere to indicate that it won’t work with the LUIS formats might save someone some time trying to work out why the dates are always coming back as ‘undefined’ .

Could you tell me where this comes in terms of priority and potential delivery date?

This is a feature that we’re very dependent upon. A lot of what we’re using LUIS for is date — or date range — related, and was one of the reasons to go with the BotFramework/LUIS combination.

Sadly we simply don’t have the resources to be able to contribute to add this functionality at the moment. Do things like this generally get added to the C# library before the implementation in NodeJS? I’m just trying to get my head around how aligned the two sub-projects are when it comes to functionality.

@SeanSobey
Copy link

SeanSobey commented Sep 20, 2016

Based on my poking around in the Node and .Net versions, the LUIS docs and my own tests I have had success with parsing datetime and duration with using moment.js (and also underscore):

//https://www.microsoft.com/cognitive-services/en-us/luis-api/documentation/pre-builtentities
const datetimeDateEntities = EntityRecognizer.findAllEntities(entities, 'builtin.datetime.date');
const datetimeDurationEntities = EntityRecognizer.findAllEntities(entities, 'builtin.datetime.duration');

//https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Tests/Microsoft.Bot.Builder.Tests/LuisResolutionTests.cs

const dateTimeDateMoments = _(datetimeDateEntities).collect((datetimeDateEntity: any) => moment(datetimeDateEntity.resolution.date  //, moment.ISO_8601 (without this we use the auto-detect feature of moment)
.replace("XXXX", moment().year())
.replace("WXX-XX", 'W' + moment().week() + '-' + moment().day())
.replace("WXX", 'W' + moment().week())
.replace("XX", moment().month())
.replace("XX", moment().day())));

const datetimeDurationDurations = _(datetimeDurationEntities).collect((datetimeDurationEntity: any) => moment.duration(datetimeDurationEntity.resolution.duration));

+1 for proper support in the SDK's soon!

@willportnoy
Copy link
Member

@R2dical thank you for sharing some code to parse the datetime resolutions. We have items in our internal backlog to track LUIS entity resolution parsing and interpretation so I'm going to close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants