Ejemplo n.º 1
0
        private async Task <RecognizerResult> Recognize(LuisRequest request, CancellationToken ct, bool verbose)
        {
            var luisResult = await _luisService.QueryAsync(request, ct).ConfigureAwait(false);

            var recognizerResult = new RecognizerResult
            {
                Text        = request.Query,
                AlteredText = luisResult.AlteredQuery,
                Intents     = GetIntents(luisResult),
                Entities    = GetEntitiesAndMetadata(luisResult.Entities, luisResult.CompositeEntities, verbose)
            };

            return(recognizerResult);
        }
        public static (string key, double score) GetTopScoringIntent(this RecognizerResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (result.Intents == null)
            {
                throw new ArgumentNullException(nameof(result.Intents));
            }

            var topIntent = (string.Empty, 0.0d);

            foreach (var intent in result.Intents)
            {
                var score = (double)intent.Value;
                if (score > topIntent.Item2)
                {
                    topIntent = (intent.Key, score);
                }
            }
            return(topIntent);
        }