public string GoOutAnnoucement() { PureFact factJob = (PureFact)factsManager.GetByName("UserHasJob"); bool userWorks = factJob.IsAnswered && this.IsYes(factJob.Value); var options = (new string[] { "You should go out this evening with your friends.", "Call somebody and go for a drink this evening.", "Today is " + KorraModelHelper.DayOfWeek() + ". It is pizza day. You better have something to eat outside." //TODO: check if it evening, or lunch time }).ToList(); if (userWorks) { options.Add("Call some friends and go for a drink after work."); options.Add("Going to a bar after work sounds like a great idea"); options.Add("Do you have plans for this evening after work? You better go out and have a drink at the local pub."); } else { options.Add("Call some friends and go for a drink."); options.Add("Going to a bar this evening sounds like a great idea."); options.Add("Do you have plans for this evening? You better go out and have a drink at the local pub."); } //choose a statement randomly string text = KorraModelHelper.GetChance(options.ToArray(), lastGoOutAnnouncementUsed); lastGoOutAnnouncementUsed = text; return(text); }
public string MovieAnnouncement(Movie movie) { string type = ((movie.IsTvSeries) ? "TV series" : "movie"); string movieName = movie.Text; string text = KorraModelHelper.GetChance(new string[] { "How about this " + type + " " + movieName + "? I recommend it.", //1 "I have a new " + type + " suggestion for you. It is called : " + movieName + ". You should try it.", //2 (KorraModelHelper.GetChance(3) ? "Do you feel bored? " : "") + "I recommend you to watch the " + type + " " + movieName + ".", //3 "Time for something interesting to watch. Try this one: " + movieName + ".", //4 "You are going to like this " + type + ": " + movieName + ". I highly recommend it." //5 }); if (KorraModelHelper.GetChance(3)) { text += " Its score on the Internet movie database is high."; } if (KorraModelHelper.GetChance(5)) { text += " It is really good. You will thank me later."; } if (KorraModelHelper.GetChance(10)) { text += " It is one of my favorite."; } return(text); }
public string SayHello() { PureFact numberOfStarts = (PureFact)factsManager.GetByName("SystemStartsCount"); int numberOfStartsInt = Convert.ToInt32(numberOfStarts.Value); string text = ""; if (!string.IsNullOrEmpty(factsManager.GetValueByName("UserName"))) //we know how the user's name { text = KorraModelHelper.GetChance(new string[] { "Hi", "Hello", "Hey", }); if (KorraModelHelper.GetChance(3) && numberOfStartsInt > 1 && (text == "Hi" || text == "Hello")) //again version { text += " again"; } text += " " + factsManager.GetValueByName("UserName"); } else //we do NOT know how the user's name { if (KorraModelHelper.GetChance(3) && numberOfStartsInt > 1) { text = KorraModelHelper.GetChance(new string[] { "Hi again", "Hello again", }); //again version } else { text = KorraModelHelper.GetChance(new string[] { "Hi", "Hello", "Hey", "Hello there", "Hey buddy" }); } } return(text); }
public string ChangeClothesAnnouncement() { string text = KorraModelHelper.GetChance(new string[] { "I am going to change my clothes. I feel better like this.", "Time for another outfit.", "Time for some change!", "I am in a mood to change my outfit." }, lastClothesAnnouncementUsed); lastClothesAnnouncementUsed = text; return(text); }
private void DisablePlayMusicAftertInitialGreeting(ref List <CommItem> list, ItemManager[] managers) { if (list.Count > 0 && list[0].IsGreeting && //to make sure it is the start of the session list[1].Category == ActionsEnum.MakeSuggestion && list[1].SubCategory == SuggestionsEnum.ListenToSong) { KorraModelHelper.RemoveInteraction(ref list, 1, managers); } }
/// <summary> /// /// </summary> /// <param name="value">is the answer to question: UserRelationshipFirstStep</param> /// <returns></returns> public string ProcessNationality(string value, out bool isValid, out string faceExpr) { bool validNationality = KorraModelHelper.CheckValidNationality(value); isValid = true; faceExpr = ""; bool validCountryName = false; if (!validNationality) { validCountryName = KorraModelHelper.CheckValidCountryName(value); } string[] uk = { "uk", "english", "scot", "welsh", "irish", "scottish", "united kingdom", "british" }; string[] sc = { "zerg", "protoss", "terran" }; string[] st = { "vulcan", "romulan", "klingon", "borg" }; if (!validNationality && !validCountryName && !uk.Contains(value.ToLower()) && !sc.Contains(value.ToLower())) { //FlagsShared.RequestSurpriseExpression = true; faceExpr = FaceExp.SurpriseOnStartTalking; isValid = false; return("Sorry, I could not understand your nationality."); } else { if (value.ToLower() == "french" || value.ToLower() == "france") { return("Hands down, best wines and cheese."); } else if (value.ToLower() == "american" || value.ToLower() == "us" || value.ToLower() == "usa") { return("<prosody pitch=\"+0%\">Yeah, the problem with political jokes is that <break time=\"800ms\"/>they get elected.</prosody>"); //maybe it should be in jokes list } else if (value.ToLower() == "canadian" || value.ToLower() == "canada") { return("<prosody pitch=\"+0%\">What do you call a sophisticated American?<break time=\"900ms\"/> A canadian.</prosody>"); //maybe it should be in jokes list } else if (uk.Contains(value.ToLower())) { return("<prosody pitch=\"+0%\">What does the Loch Ness monster eat?<break time=\"900ms\"/> Fish and ships.</prosody>"); //maybe it should be in jokes list } else if (sc.Contains(value.ToLower())) { return("<prosody pitch=\"+0%\">Oh. A Starcraft fan. <break time=\"500ms\"/>Shields up, weapons online!</prosody>"); //maybe it should be in jokes list } else if (st.Contains(value.ToLower())) { return("<prosody pitch=\"+0%\">Oh. A Star Trek fan. <break time=\"500ms\"/>Resistance is futile</prosody>"); //maybe it should be in jokes list } return(""); } }
private string AddCallByName(string originalText, string username) { if (!string.IsNullOrEmpty(username) && (KorraModelHelper.GetChance(3))) //33% chance to use the name { return(KorraModelHelper.FirstCharToUpper(username) + ", " + KorraModelHelper.FirstCharToLower(originalText)); } else { return(originalText); } }
public string ExitQuestion() { if (KorraModelHelper.GetChance(2)) { return("You want to go?"); } else { return("You need to go?"); } }
public string ILookGood() //currently not used { string value = KorraModelHelper.GetChance(new string[] { "I really look gorgeous!", "I look <prosody rate=\"-40%\">awe</prosody><prosody volume=\"loud\">some</prosody>.", }, lastILookGood); lastILookGood = value; if (KorraModelHelper.GetChance(3)) { value = "I think " + value; } return(value); }
public string ExpressBotGoodMood() { //TODO: currently does not use probabilstic variable to encode the inAGoodMood string response = ""; response = KorraModelHelper.GetChance(new string[] { "I am doing OK.", "I am in a good mood today." }, lastBotGoodMood); lastBotGoodMood = response; return(response); }
public static string AddJokeAnnouncement(string originalText) { string text = ""; string start = "<prosody pitch=\"+0%\">"; string pause = "<break time=\"800ms\"/>"; //maybe it should not be fixed string end = "</prosody>"; text = KorraModelHelper.GetChance(new string[] { start + "Joke time. " + pause + originalText + end, start + "I would like to tell you a joke. " + pause + originalText + end, start + originalText + pause + " OK, that was a joke." + end, originalText }); return(text); }
public string VideoPlaybackError() { string value = KorraModelHelper.GetChance(new string[] { "Sorry. Music playback did not work.", "Oops. There was a problem with music playback.", }, lastMusicFailure); lastMusicFailure = value; if (KorraModelHelper.GetChance(3)) { if (KorraModelHelper.GetChance(2)) { value += " I know it is a ridiculous question, but "; } value += " Are you sure you are connected to the internet? "; if (KorraModelHelper.GetChance(2)) { value += " Please, play some Youtube videos to verify that."; } } return(value); }
//Avoid last one used? YES private string AddSongAnnouncement(string originalText, bool oneSongAlreadyPlanned) { string text = ""; if (oneSongAlreadyPlanned || StatesShared.OneSongAlreadyPlayed) { string value = KorraModelHelper.GetChance(new string[] { "I have a new song for you: ", "Another song: ", "You are going to like this tune: ", "Listen to this song: ", "I am going to play some music: " }, lastSongAnnouncementUsed); lastSongAnnouncementUsed = value; text += (value + originalText) + "."; } else { text += KorraModelHelper.GetChance(new string[] { "I have a nice song for you: ", "Listen to this song: ", "I am going to play some music: " }); text += originalText + "."; text += " Please note that pressing " + ((FlagsShared.IsMobile) ? "Back button" : "Escape") + " at anytime will stop playback."; } return(text); }
public void InteractionsUpdate(TimeSpan timeSinceStart, int interactionsDoneSinceStart, ref Queue <CommItem> interactions) { if (!isInitialized) { SharedHelper.LogError("Not initialized."); return; } //Evaluate triggers that represent 'Surprise' for example //These triggers evaluate a model and add a new interaction foreach (var trigger in ModelTriggers) { int oldExecuteCount = trigger.TriggeredCount; if (trigger is IModelEvaluateTrigger && ( (trigger.IsOneTimeTrigger && trigger.TriggeredCount == 0) || (!trigger.IsOneTimeTrigger) ) ) { CommItem?newInteraction = ((IModelEvaluateTrigger)trigger).Process(this); if (newInteraction != null) { if (interactions.Peek().Name != newInteraction.Value.Name) { KorraModelHelper.InsertFirstInteractionList(ref interactions, newInteraction.Value); //TODO: this custom code should be moved to another place if (trigger is VideoGameSurpriseTrigger) { FlagsShared.RequestSurpriseExpression = true; } SharedHelper.Log("Trigger executed: '" + trigger.ToString() + "'"); } } } } }
public string SayGoodBye() { string text = "OK, "; string Username = factsManager.GetValueByName("UserName"); if (!string.IsNullOrEmpty(Username)) { Username = KorraModelHelper.FirstCharToUpper(Username); } text += KorraModelHelper.GetChance(new string[] { (KorraModelHelper.GetChance(3)) ? "bye" : "goodbye", "See you soon", "Have a good day" }); if (!string.IsNullOrEmpty(Username)) { text += " " + Username; } text += "."; return(text); }
public string MovieSuggestions() { string text = KorraModelHelper.GetChance(new string[] { "I will have some suggestions for you later today.", "Later I can recommend you a few good ones." }); return(text); }
public Queue <CommItem> ProcessItems(Queue <CommItem> input, ItemManager[] managers) { PureFacts pfManager = (PureFacts)managers.SingleOrDefault(x => x is PureFacts); if (pfManager == null) { SharedHelper.LogError("No Pure Fact Manager in SpeechAdaptationEN."); return(null); } List <CommItem> list = input.ToList(); if (!FlagsShared.InitialGreetingPerformed) { list.Insert(0, new CommItem { TextToSay = phrases.SayHello(), IsGreeting = true }); FlagsShared.InitialGreetingPerformed = true; } string username = pfManager.GetValueByName("UserName"); for (int i = 0; i < list.Count; i++) { //add joke announcement //if (list[i].Action == Actions.MakeSuggestion && list[i].Suggestion == Suggestions.TellJoke) //{ // CommItem item = list[i]; // item.TextToSay = AddJokeAnnouncement(item.TextToSay); // list[i] = item; //} //add song announcement if (list[i].Category == ActionsEnum.MakeSuggestion && list[i].SubCategory == SuggestionsEnum.ListenToSong) { CommItem item = list[i]; item.TextToSay = AddSongAnnouncement(item.TextToSay, OneSongAlreadyPlanned); list[i] = item; OneSongAlreadyPlanned = true; } // add user name for the interaction if (list[i].Category == ActionsEnum.AskUncertanFactQuestion || list[i].SubCategory == ActionsEnum.AskPureFactQuestionAboutUser || list[i].Category == ActionsEnum.ChangeVisualAppearance || (list[i].Category == ActionsEnum.MakeSuggestion && list[i].SubCategory != "" && list[i].SubCategory != SuggestionsEnum.TellJoke) ) { CommItem item = list[i]; item.TextToSay = AddCallByName(item.TextToSay, username); list[i] = item; } } DisablePlayMusicAftertInitialGreeting(ref list, managers); KorraModelHelper.CoupleTwoInteractionsTogether(ref list, "UserName", "BotName"); KorraModelHelper.CoupleTwoInteractionsTogether(ref list, "UserLikesVideoGames", "UserThinksVideoGameIsGoodPresent"); return(new Queue <CommItem>(list)); }
public bool AdjustProbVariablesDuringPlanning(int bufferedInteractionsCount) { bool regenerate = false; //1. About bot //exclude this action because there are no items for it if (ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current].Value != 0 && KorraModelHelper.GetItemsLeftForSubCategory(ActionsEnum.SharePureFactInfoAboutBot, ItemProviders) == 0) { //adjust pure facts probabilities: disable AboutBot and boost AboutUser ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current] = Prob(0); SharedHelper.LogWarning("Disabled all pure facts about bot, because there were no items."); //we re-inforce AboutUser so that it is stronger than Suggestion action if (ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current].Value > 0) { ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current] = ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Increased]; } regenerate = true; } //2. About User //exclude this action because there are no items for it if (ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current].Value != 0 && KorraModelHelper.GetItemsLeftForSubCategory(ActionsEnum.AskPureFactQuestionAboutUser, ItemProviders) == 0) { //adjust pure facts probabilities: disable AboutUser and boost AboutBot ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current] = Prob(0); SharedHelper.Log("Disabled all pure facts about user, because there were no items."); //we re-inforce AboutBot so that it is stronger than Suggestion action if (ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current].Value > 0) { ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current] = ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Increased]; } regenerate = true; } //3. Suggestions //if there are no Pure or Uncertain facts left then we boost suggestions bool noFactsLeft = (ProbVariables.Bot.PrAskPureFactQuestionAboutUser[(int)PV.Current].Value == 0 && ProbVariables.Bot.PrSharePureFactInfoAboutBot[(int)PV.Current].Value == 0); if (noFactsLeft && ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current] != ProbVariables.Bot.PrMakeSuggestion[(int)PV.Default]) { ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current] = ProbVariables.Bot.PrMakeSuggestion[(int)PV.Default]; SharedHelper.Log("All pure facts used. PrMakeSuggestion changed to: " + ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current]); } //Keep suggestions decreased if there are more pure facts if (!noFactsLeft && ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current] != ProbVariables.Bot.PrMakeSuggestion[(int)PV.Descreased]) { SharedHelper.Log("PrMakeSuggestion changed decreased."); ProbVariables.Bot.PrMakeSuggestion[(int)PV.Current] = ProbVariables.Bot.PrMakeSuggestion[(int)PV.Descreased]; } return(regenerate); }
/// <summary> /// Configures when facial expressions are used /// </summary> /// <param name="item"></param> public void SetFacialExpression(CommItem item) { #region Get Fact Manager PureFacts pfManager = (PureFacts)ItemProviders.SingleOrDefault(x => x is PureFacts); if (pfManager == null) { SharedHelper.LogError("No manager in Facts Manager in SetFacialExpression for model " + this.Name); return; } #endregion //PureFacts and Jokes will facial expression set at this stage or by Dynamic Function //it updates the facial expression, if it is empty if (!string.IsNullOrEmpty(item.FacialExpression)) { KorraModelHelper.SetFacialExpressionFlag(item.FacialExpression); } else //here in most cases we default to smile { if (item.IsReactionToUser) //default to smile on reaction { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } else //Handle PureFacts AboutBot if (item.IsPureFact && !item.IsJokePureFact) { PureFact fact = (PureFact)pfManager.GetByName(item.Name); if (fact != null && fact.Type == PureFactType.AboutBot) { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } } else if (item.Category == ActionsEnum.ChangeVisualAppearance) { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } else if (item.Category == ActionsEnum.ConvinceBuyStatement) { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } else if (item.Category == ActionsEnum.ExpressMentalState) { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } else //Hnadle Jokes (Normal or PureFacts) if (item.SubCategory == SuggestionsEnum.TellJoke && !item.IsJokePureFact) { if (!item.IsJokePureFact) //Normal joke { Joke joke = JokesProvider.GetJokeByName(item.Name); if (joke != null && !string.IsNullOrEmpty(joke.FaceExpression)) //check for custom facial expression { KorraModelHelper.SetFacialExpressionFlag(joke.FaceExpression); } else { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); //default to smile } } else //PureFact joke that had no facial expression set { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); //default to smile } } else if (item.SubCategory == SuggestionsEnum.ListenToSong || item.SubCategory == SuggestionsEnum.DoSport || item.SubCategory == SuggestionsEnum.WatchMovie || item.SubCategory == SuggestionsEnum.GoOut) { KorraModelHelper.SetFacialExpressionFlag(FaceExp.SmileAfterTalking); } } }