Search code examples
c#datetimebotsazure-language-understanding

Parse LUIS builtin.datetime.date


I have built a Luis model, and I have encountered issues parsing the builtin.datetime.date for an entry like "this weeked" returns 2016-W20-WE (or something similar) which doesnt parse successfuly using DateTime.Parse.

I came across this post which seems to use a class called LUISParse, but I can't find any reference to this on Google.


Solution

  • I have the same problem and see that in their sdk doc they use Chronic on the actual entity string rather than trying to interpret the date format. See Here:

    So I did something like this:

    Chronic.Parser parser = new Chronic.Parser();
    EntityRecommendation date = new EntityRecommendation();
    luisResponse.TryFindEntity("builtin.datetime.date", out date);
    var dateResult = parser.Parse(date.Entity);
    

    It works since the date.Entity only contains the date related string. Ex: I pass in "Yes I am planning to go next week" to Luis and the entity contains "next week".