예제 #1
0
        public async Task <LuisResponse> SendQuery(string query)
        {
            string requestUrl = $"{ApiBaseUrl}id={_applicationId}&subscription-key={_subscriptionKey}&q={query}";

            using (HttpClient client = new HttpClient())
            {
                HttpRequestMessage  request  = new HttpRequestMessage(HttpMethod.Get, requestUrl);
                HttpResponseMessage response = await client.SendAsync(request);

                string content = await response.Content.ReadAsStringAsync();

                LuisResponse result = JsonConvert.DeserializeObject <LuisResponse>(content);
                return(result);
            }
        }
예제 #2
0
        public static Intent Winner(this LuisResponse luisResponse)
        {
            if (!luisResponse.Intents.Any())
            {
                return(null);
            }

            Intent winner = luisResponse.Intents.First();

            for (int i = 1; i < luisResponse.Intents.Count; ++i)
            {
                if (luisResponse.Intents[i].Score > winner.Score)
                {
                    winner = luisResponse.Intents[i];
                }
            }

            return(winner);
        }