public async Task <T> RecognizeAsync <T>(ITurnContext turnContext, CancellationToken cancellationToken) where T : IRecognizerConvert, new() { var mockResult = new T(); var t = typeof(T); var text = turnContext.Activity.Text; if (t.Name.Equals(typeof(CalendarLuis).Name)) { CalendarLuis mockCalendar = utterancesManager.GetValueOrDefault(text, utterancesManager.GetBaseNoneIntent()); var test = mockCalendar as object; mockResult = (T)test; } else if (t.Name.Equals(typeof(General).Name)) { var mockGeneralIntent = generalUtterancesManager.GetValueOrDefault(text, generalUtterancesManager.GetBaseNoneIntent()); var test = mockGeneralIntent as object; mockResult = (T)test; } return(await Task.FromResult(mockResult)); }
// Check whether the SlotAttributeName contains the specific slotName private static bool ContainSlotName(CalendarLuis luis, string slotName) { if (luis == null || luis.Entities == null || luis.Entities.SlotAttributeName == null) { return(false); } for (int i = 0; i < luis.Entities.SlotAttributeName.Length; i++) { if (luis.Entities.SlotAttributeName[i][0] == slotName) { return(true); } } return(false); }
/* * SlotAttributeName is entity list, while SlotAttribute is simple entity. SlotAttributeName is the canonical form of SlotAttribute. * When both SlotAttributeName and SlotAttribute are recognized(SlotAttributeName may be a part of SlotAttribute), this entity is confirmed. */ private static bool ContainSlot(CalendarLuis luis, string slotName) { if (luis == null || luis.Entities == null || luis.Entities.SlotAttributeName == null || luis.Entities.SlotAttribute == null) { return(false); } for (int i = 0; i < luis.Entities.SlotAttributeName.Length; i++) { for (int j = 0; j < luis.Entities.SlotAttribute.Length; j++) { if (luis.Entities.SlotAttributeName[i][0] == slotName && luis.Entities._instance.SlotAttribute[j].Text.Contains(luis.Entities._instance.SlotAttributeName[i].Text) && luis.Entities._instance.SlotAttributeName[i].StartIndex >= luis.Entities._instance.SlotAttribute[j].StartIndex && luis.Entities._instance.SlotAttributeName[i].EndIndex <= luis.Entities._instance.SlotAttribute[j].EndIndex) { return(true); } } } return(false); }
public static bool ContainFloorSlot(CalendarLuis luis) { return(ContainSlotName(luis, SlotNames.Floor)); }
public static bool ContainBuildingSlot(CalendarLuis luis) { return(ContainSlotName(luis, SlotNames.Building)); }
public static bool ContainTimeSlot(CalendarLuis luis) { return(ContainSlot(luis, SlotNames.Time)); }
public static bool ContainMeetingRoomSlot(CalendarLuis luis) { return(ContainSlot(luis, SlotNames.Room)); }