public async Task None(IDialogContext context, Microsoft.Bot.Builder.Luis.Models.LuisResult result) { string message = $"ゴメンナサイ...日本語分かりませんでした"; await context.PostAsync(message); context.Wait(MessageReceived); }
public async Task Greeting(IDialogContext context, Microsoft.Bot.Builder.Luis.Models.LuisResult result) { string message = $"こんにちは!日本の各地の天気をお答えするお天気BOTです。"; await context.PostAsync(message); context.Wait(MessageReceived); }
public async Task ConfirmWeather(IDialogContext context, Microsoft.Bot.Builder.Luis.Models.LuisResult result) { string city = "東京"; string datetime = "今日"; EntityRecommendation eRecommend; if (result.TryFindEntity("City", out eRecommend)) { city = eRecommend.Entity; } if (result.TryFindEntity("DateTime::Day", out eRecommend)) { datetime = eRecommend.Entity; } string message = "[都市名]" + city + " [日付]" + datetime + " の天気を確認しますね"; await context.PostAsync(message); context.Wait(MessageReceived); }
/// <summary> /// Look for an acceptable match between the 'userName' entities found by LUIS and /// the known set of user names for the user's club. Consider the first name, last /// name, and username for each user. /// </summary> /// <param name="userState">The user context</param> /// <param name="result">The result returned by LUIS</param> /// <returns>The JToken for the matching user, or null if no good match was found.</returns> public static async Task<Tuple<JToken, string>> FindBestUserMatchAsync(this UserState userState, LuisResult result) { var entities = result.Entities; var entityWords = entities .Where(e => e.Type == LuisResultExtensions.EntityRowerName) .SelectMany(e => e.Entity.ToLower().Split(' ')) .ToList(); if (entityWords.Count == 0) { return new Tuple<JToken, string>(null, "I'm sorry, but I didn't see anything that looked like a user name."); } var users = await BookedSchedulerCache.Instance[userState.ClubId].GetUsersAsync(); // If the boats are named sensibly, there should be only one perfect match. var user = users.FirstOrDefault((b) => PerfectMatchUser(entityWords, b)); if (user != null) { return new Tuple<JToken, string>(user, null); } // // Next, check to see if a subset of the entities completely spans the user name words. // This could happen if LUIS classifies "extra" words as being part of the user name. // var overMatches = users.Where((b) => OverMatchUser(entityWords, b)); switch (overMatches.Count()) { case 0: break; // fall through and check for "under-matches" case 1: return new Tuple<JToken, string>(overMatches.First(), null); default: // Multiple matches - ask for clarification. var userNames = overMatches.Select(u => $"'{u.FullName()}'"); return new Tuple<JToken, string>(null, $"I think you meant one of these users ({string.Join(", ", userNames)}). Can you be more specific?"); } // // Next, check for cases where the entities all match a subset of the user name words. // This could happen if LUIS failed to classify some words as being part of the user // name OR if the user provides only a portion of a longer name. // var underMatches = users.Where((b) => UnderMatchUser(entityWords, b)); // TODO: If one partial match is superior to all others, we should allow it. switch (underMatches.Count()) { case 0: return new Tuple<JToken, string>(null, $"I'm sorry, but I didn't find any good matches for '{result.UserName()}' in your club's member list."); case 1: return new Tuple<JToken, string>(underMatches.First(), null); default: // Multiple matches - ask for clarification. var userNames = underMatches.Select(u => $"'{u.FullName()}'"); return new Tuple<JToken, string>(null, $"I think you meant one of these users ({string.Join(", ", userNames)}). Can you be more specific?"); } }