protected async Task DigestLuisResult(DialogContext dc, PointOfInterestLuis luisResult) { try { var state = await Accessor.GetAsync(dc.Context, () => new PointOfInterestSkillState()); if (luisResult != null) { var entities = luisResult.Entities; if (entities.KEYWORD != null) { state.Keyword = string.Join(" ", entities.KEYWORD); } if (entities.ADDRESS != null) { state.Address = string.Join(" ", entities.ADDRESS); } if (entities.ROUTE_TYPE != null) { state.RouteType = entities.ROUTE_TYPE[0][0]; } if (entities.number != null) { try { var value = entities.number[0]; if (Math.Abs(value - (int)value) < double.Epsilon) { state.UserSelectIndex = (int)value - 1; } } catch { // ignored } } } } catch { // put log here } }
private async Task DigestLuisResult(DialogContext dc, PointOfInterestLuis luisResult) { try { var state = await _stateAccessor.GetAsync(dc.Context, () => new PointOfInterestSkillState()); if (luisResult != null) { state.Clear(); var entities = luisResult.Entities; // TODO since we can only search one per search, only the 1st one is considered if (entities.Keyword != null) { if (entities._instance.KeywordCategory == null || !entities._instance.KeywordCategory.Any(c => c.Text.Equals(entities.Keyword[0], StringComparison.InvariantCultureIgnoreCase))) { state.Keyword = entities.Keyword[0]; } } // TODO if keyword exists and category exists, whether keyword contains category or a keyword of some category. We will ignore category in these two cases if (string.IsNullOrEmpty(state.Keyword) && entities._instance.KeywordCategory != null) { state.Category = entities._instance.KeywordCategory[0].Text; } if (entities.Address != null) { state.Address = string.Join(" ", entities.Address); } else { // ADDRESS overwrites geographyV2 var sb = new StringBuilder(); if (entities.geographyV2 != null) { sb.AppendJoin(" ", entities.geographyV2.Select(geography => geography.Location)); } if (sb.Length > 0) { state.Address = sb.ToString(); } } // TODO only first is used now if (entities.RouteDescription != null) { state.RouteType = entities.RouteDescription[0][0]; } if (entities.PoiDescription != null) { state.PoiType = entities.PoiDescription[0][0]; } // TODO unused if (entities.number != null) { try { var value = entities.number[0]; if (Math.Abs(value - (int)value) < double.Epsilon) { state.UserSelectIndex = (int)value - 1; } } catch { // ignored } } } } catch { // put log here } }
private async Task DigestLuisResult(DialogContext dc, PointOfInterestLuis luisResult) { try { var state = await _stateAccessor.GetAsync(dc.Context, () => new PointOfInterestSkillState()); if (luisResult != null) { state.ClearLuisResults(); var entities = luisResult.Entities; if (entities.KEYWORD != null) { state.Keyword = string.Join(" ", entities.KEYWORD); } if (entities.ADDRESS != null) { state.Address = string.Join(" ", entities.ADDRESS); } else { // ADDRESS overwrites geographyV2 var sb = new StringBuilder(); if (entities.geographyV2_poi != null) { sb.AppendJoin(" ", entities.geographyV2_poi); } if (entities.geographyV2_city != null) { sb.AppendJoin(" ", entities.geographyV2_city); } if (sb.Length > 0) { state.Address = sb.ToString(); } } if (entities.ROUTE_TYPE != null) { state.RouteType = entities.ROUTE_TYPE[0][0]; } if (entities.number != null) { try { var value = entities.number[0]; if (Math.Abs(value - (int)value) < double.Epsilon) { state.UserSelectIndex = (int)value - 1; } } catch { // ignored } } } } catch { // put log here } }
private async Task DigestLuisResult(DialogContext dc, PointOfInterestLuis luisResult) { try { var state = await _stateAccessor.GetAsync(dc.Context, () => new PointOfInterestSkillState()); if (luisResult != null) { state.Clear(); state.LuisResult = luisResult; var entities = luisResult.Entities; if (entities.Keyword != null) { state.Keyword = string.Join(" ", entities.Keyword); } if (entities.Address != null) { state.Address = string.Join(" ", entities.Address); } else { // ADDRESS overwrites geographyV2 var sb = new StringBuilder(); if (entities.geographyV2 != null) { sb.AppendJoin(" ", entities.geographyV2.Select(geography => geography.Location)); } if (sb.Length > 0) { state.Address = sb.ToString(); } } // TODO only first is used now if (entities.RouteDescription != null) { state.RouteType = entities.RouteDescription[0][0]; } if (entities.PoiDescription != null) { state.PoiType = entities.PoiDescription[0][0]; } // TODO unused if (entities.number != null) { try { var value = entities.number[0]; if (Math.Abs(value - (int)value) < double.Epsilon) { state.UserSelectIndex = (int)value - 1; } } catch { // ignored } } } } catch { // put log here } }