private async void OnTestLuisAppFlyoutOpened(object sender, object e) { try { // Run LUIS app tests this.luisAppTestResultTextBox.Text = ""; string[] utterances = { "I'd like to get a hat", "I am more interested in sunglasses", "Caps for me", "Blah-blah-blah" }; for (int i = 0; i < utterances.Length; i++) { string entity = await LuisServiceHelper.GetEntity(utterances[i]); this.luisAppTestResultTextBox.Text += $"utterance: '{utterances[i]}'\n=> entity: '{entity}'\n"; } } catch (Exception ex) { this.luisAppTestResultTextBox.Text = ex.Message; } }
public async Task <ActionResult> Search(SearchModel model) { List <AzureSearchResultModel> searchResults = new List <AzureSearchResultModel>(); try { var luisResult = await LuisServiceHelper.SearchIntent(model.SearchText); var entities = luisResult.Entities.Where(e => e.Score > 0.6).Select(t => t).ToArray(); foreach (var entity in entities) { var searchResult = await SearchServiceHelper.SearchAsync(entity.Entity); var docs = searchResult.Results.Select(s => s.Document).ToArray(); searchResults.AddRange(docs); model.DetectedEntities.Add(entity.Entity); model.SearchResults = searchResults; } return(View(model)); } catch (Exception ex) { Console.WriteLine(ex.Message); return(View(model)); } }
public async Task <string> RecognizeChoice() { string entity = ""; if (this.isUsingSpeech) { string speechText = await SpeechToTextServiceHelper.GetTextFromSpeechAsync(); if (this.isDebugInfo) { this.debugInfo.Text = string.IsNullOrEmpty(speechText) ? "" : speechText; } entity = await LuisServiceHelper.GetEntity(speechText); if (this.isDebugInfo) { string text = this.debugInfo.Text; this.debugInfo.Text = $"{text} => {entity}"; } } return(entity); }