Exemplo n.º 1
0
        /// <summary>
        /// Query the LUIS service using this request.
        /// </summary>
        /// <param name="service">LUIS service.</param>
        /// <param name="request">Query request.</param>
        /// <param name="token">Cancellation token.</param>
        /// <returns>LUIS result.</returns>
        public static async Task <LuisResult> QueryAsync(this ILuisService service, LuisRequest request, CancellationToken token)
        {
            service.ModifyRequest(request);
            var uri = service.BuildUri(request);

            return(await service.QueryAsync(uri, token));
        }
        private Task <RecognizerResult> RecognizeInternal(string utterance, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(utterance))
            {
                throw new ArgumentNullException(nameof(utterance));
            }

            var luisRequest = new LuisRequest(utterance);

            _luisOptions.Apply(luisRequest);
            return(Recognize(luisRequest, ct, _luisRecognizerOptions.Verbose));
        }
Exemplo n.º 3
0
        public Task <(RecognizerResult recognizerResult, LuisResult luisResult)> CallAndRecognize(string utterance, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(utterance))
            {
                throw new ArgumentNullException(nameof(utterance));
            }

            var luisRequest = new LuisRequest(utterance);

            _luisOptions.Apply(luisRequest);
            return(Recognize(luisRequest, ct, _luisRecognizerOptions.Verbose));
        }
        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    = ExtractEntitiesAndMetadata(luisResult.Entities, luisResult.CompositeEntities, verbose),
            };

            recognizerResult.Properties.Add("luisResult", luisResult);
            return(recognizerResult);
        }
Exemplo n.º 5
0
 Uri ILuisService.BuildUri(LuisRequest luisRequest)
 {
     return(luisRequest.BuildUri(this.model));
 }
Exemplo n.º 6
0
 public LuisRequest ModifyRequest(LuisRequest request)
 {
     return(model.ModifyRequest(request));
 }
 /// <summary>
 /// Applies the optional parameters from this object to a LUIS request.
 /// </summary>
 /// <param name="request">The LUIS request to modify.</param>
 /// <returns>The modified request.</returns>
 public LuisRequest ModifyRequest(LuisRequest request)
 {
     Options.Apply(request);
     return(request);
 }
Exemplo n.º 8
0
 Uri ILuisService.BuildUri(LuisRequest luisRequest) => luisRequest.BuildUri(this.model);
Exemplo n.º 9
0
 /// <summary>
 /// Using this service's <see cref="ILuisModel"/>, modifies a LUIS request to specify
 /// query parameters like spelling or logging.
 /// </summary>
 /// <param name="request">The request to modify.</param>
 /// <returns>The modified request.</returns>
 public LuisRequest ModifyRequest(LuisRequest request) => model.ModifyRequest(request);
Exemplo n.º 10
0
 public LuisRequest ModifyRequest(LuisRequest request)
 {
     return(request);
 }