Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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));
        }