1
votes

Utterance : I want to book a flight from Hyderabad to Bangalore next Monday preferably around afternoon with a return on next Friday preferably around evening .

Entities: FromDestination : Hyderabad,

ToDestination: Bangalore

Prebuilt Enties: Buiiltin.DateTimeV2 : Next Monday, Friday.

Builtin.DateTimeV2.TimeRange : Afternoon , Evening

.NET Code to recognize enties:

       foreach(EntityRecommendation obj in result.Entities)
            {
                if(obj.Type == FlightBotConstants.fromDestination)
                {
                    context.PrivateConversationData.SetValue<string>("fromDestination", Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(obj.Entity.ToLower()));
                }
                else if(obj.Type == FlightBotConstants.toDestination)
                {
                    context.PrivateConversationData.SetValue<string>("toDestination", Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(obj.Entity.ToLower()));
                }
                else if(obj.Type == FlightBotConstants.prebuiltdate)
                {
                    Chronic.Parser depparser = new Chronic.Parser();
                    var depDateResult = depparser.Parse(obj.Entity);
                    string departureDate = depDateResult.Start.Value.ToString("yyyy-MM-dd");
                    context.PrivateConversationData.SetValue<string>("departtDate", Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(departureDate));
                }
                else if(obj.Type == FlightBotConstants.prebuilttimeRange)
                {
                    Chronic.Parser depTimeParser = new Chronic.Parser();
                    var deptimeResult = depTimeParser.Parse(obj.Entity);
                    var depStartTime = deptimeResult.Start.Value.TimeOfDay;
                    var depEndTime = deptimeResult.End.Value.TimeOfDay;
                    context.PrivateConversationData.SetValue<string>("departureStartTime", Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(depStartTime.ToString()));
                    context.PrivateConversationData.SetValue<string>("departureEndTime", Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(depEndTime.ToString()));
                }
            }

I need a output like below. How i can get exactly

Departing Location: Hyderabad

Arrival Location: Bangalore

Date of Departure: 2018-01-15

Departure Start Time: 13:00

Departure End Time: 18:00

Date of Return: 2018-01-19

Return Start Time: 19:00

Departure End Time: 22:00

I can get all entities data, but my issue is if user utterance is " I want to book a flight from Hyderabad to Bangalore next Monday with a return on next Friday preferably around evening".

How exactly i can write my code to get below output.

Departing Location: Hyderabad

Arrival Location: Bangalore

Date of Departure: 2018-01-15

Departure Start Time:

Departure End Time:

Date of Return: 2018-01-19

Return Start Time: 19:00

Departure End Time: 22:00

2

2 Answers

1
votes

Can you provide an example of what the entities returned are? Without knowing what the LUIS model I can only offer a few tips:

  • If you are correctly getting all entities, you can add the entities in a temporary list/container in your bot and then format it to suit your scenario.

  • You can try training your LUIS model around composite entities. This will allow you to associate your custom entities (FromDestination, ToDestination) with the pre-built entity of datetime.

Hope that helps

0
votes

for good LUIS will identify referential day/week/month/Year

like, datetimeV2 --> last year, datetimeV2 --> Previous year,

datetimeV2 --> next month, datetimeV2 --> last month,

datetimeV2 --> last week, datetimeV2 --> next week,

datetimeV2 --> previous day, datetimeV2 --> early next week,

datetimeV2 --> next day, datetimeV2 --> yesterday,

datetimeV2 --> tomorrow, datetimeV2 --> day before yesterday,

datetimeV2 --> day after tomorrow,

so and so forth

Similarly, datetimeV2 --> tomorrow morning, datetimeV2 --> early morning tomorrow, datetimeV2 --> today early evening,

so and so forth,

for your query " I want to book a flight from Hyderabad to Bangalore next Monday with a return on next Friday preferably around evening"

you can refer calendar for datetimeV2 -->next Monday and datetimeV2 --> next Friday and identify applicable appropriate dates. when user referred Morning or evening acknowledged the input and prompt user to specify the timings.

After all, a bot is a conversational interface, it has to ask questions and seek clarifications to help users to accomplish their objective.