async public Task IntentBaggageRestrictions(IDialogContext context, LuisResult result) { var score = result.TopScoringIntent.Score; if (true == _isDebug) { await context.PostAsync($"(Debug) query='{result.Query}'"); await context.PostAsync($"(Debug) intent_score={score}"); } // if (score < 0.95) // { // await None(context, result); // return; // } await context.PostAsync($"Пожалуйста, подождите немного пока я изучаю Ваш вопрос..."); var entitiesGeographyScored = result.ScoreEntitiesGeography(); var nGeography = (await Task.WhenAll(entitiesGeographyScored.Select(er => er.NormalizeGeography(cityFullName: false)))) .Where(n => null != n.normalized).ToArray(); _Cities = nGeography.Where(ng => LuisHelpers.BuiltInGeographyCity.Equals(ng.entity.Type, StringComparison.InvariantCultureIgnoreCase)) .Select(ng => ng.normalized).ToArray(); _Countries = nGeography.Where(ng => LuisHelpers.BuiltInGeographyCountry.Equals(ng.entity.Type, StringComparison.InvariantCultureIgnoreCase)) .Select(ng => ng.normalized).ToArray(); // var _Cities = result?.Entities // ?.Where(e => // ("builtin.geography.city".Equals(e.Type, StringComparison.InvariantCultureIgnoreCase)) // && ((e.Score ?? -1.0) >= 0.5)) // .ToArray() ?? new EntityRecommendation[0]; // // var _Countries = result?.Entities // ?.Where(e => // ("builtin.geography.country".Equals(e.Type, StringComparison.InvariantCultureIgnoreCase)) // && ((e.Score ?? -1.0) >= 0.5)) // .Select(e => e.Entity) // .ToArray() ?? new String[0]; // // normalize countries // if (_Countries.Length > 0) // { // // ((BingMapsRESTToolkit.Location)(r.ResourceSets[0x00000000].Resources[0x00000000])).Address.CountryRegion // // ((BingMapsRESTToolkit.Location)(r.ResourceSets[0x00000000].Resources[0x00000000])).Confidence // // r.StatusCode // // r.errorDetails // // _Countries = (await Task.WhenAll( // _Countries.Select(ct => ServiceManager.GetResponseAsync(new GeocodeRequest() // { // BingMapsKey = "AngIydqdFB0kbCLQDr3vVqPbHiDOLYvCBNreIYwxtCoekUKBpuKwTjUsHcmzg3jk", // Culture = "ru-ru", // Query = ct // }))) // ) // .Where(resp => 200 == resp.StatusCode) // // .SelectMany(resp => resp.ResourceSets) // .SelectMany(rs => rs.Resources) // // .OfType<Location>() // .Where(res => "High".Equals(res.Confidence, StringComparison.InvariantCultureIgnoreCase)) // //.Where(res => "CountryRegion".Equals(res.EntityType, StringComparison.InvariantCultureIgnoreCase)) // .Select(res => res.Address?.CountryRegion) // .Where(cr => false == String.IsNullOrEmpty(cr)) // .ToArray(); // // var iii = 0; // iii++; // // //foreach (var ct in cities) { // // var r = await ServiceManager.GetResponseAsync(new GeocodeRequest() // // { // // BingMapsKey = "AngIydqdFB0kbCLQDr3vVqPbHiDOLYvCBNreIYwxtCoekUKBpuKwTjUsHcmzg3jk", // // Query = ct.Entity // // }); // // // var countriesFromCities = r.ResourceSets.SelectMany(rs => rs.Resources) // // .OfType<Location>() // // .Where(res => "High".Equals(res.Confidence, StringComparison.InvariantCultureIgnoreCase)) // // .Select(res => res.Address?.CountryRegion) // // .ToArray(); // // //} // // } }