Пример #1
0
        private async Task <(RecognizerResult recognizerResult, LuisResult luisResult)> 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, luisResult);
        }
Пример #2
0
        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);
        }