Example #1
0
 public override string ProcessChange()
 {
     while (true)
     {
         if (Template.Name.ToLower() == "gender")
         {
             var text = Template.InnerText;
             if (text.Length > 0)
             {
                 // non atomic version of the node
                 return text.Substitute(ChatBot.Genders);
             }
             // atomic version of the node
             var starNode = GetNode("<star/>");
             var recursiveStar = new Star(Query, Request, starNode);
             Template.InnerText = recursiveStar.ProcessChange();
             if (!string.IsNullOrEmpty(Template.InnerText))
             {
                 continue;
             }
             return string.Empty;
         }
         return string.Empty;
     }
 }
Example #2
0
File: Sr.cs Project: rlebowitz/ai
        public override string ProcessChange()
        {
            if (Template.Name.ToLower() == "sr")
            {
                XmlNode starNode = GetNode("<star/>");
                Star recursiveStar = new Star(Query, Request, starNode);
                string starContent = recursiveStar.ProcessChange();

                XmlNode sraiNode = GetNode("<srai>" + starContent + "</srai>");
                Srai sraiHandler = new Srai(ChatBot, User, Request, sraiNode);
                return sraiHandler.ProcessChange();
            }
            return string.Empty;
        }
Example #3
0
        public override string ProcessChange()
        {
            while (true)
            {
                if (Template.Name.ToLower() != "sentence") return string.Empty;
                if (Template.InnerText.Length > 0)
                {
                    var result = new StringBuilder();
                    var letters = Template.InnerText.Trim().ToCharArray();
                    var doChange = true;
                    foreach (var t in letters)
                    {
                        var letterAsString = Convert.ToString(t);
                        if (ChatBot.Splitters.Contains(letterAsString))
                        {
                            doChange = true;
                        }

                        var lowercaseLetter = new Regex("[a-zA-Z]");

                        if (lowercaseLetter.IsMatch(letterAsString))
                        {
                            if (doChange)
                            {
                                result.Append(letterAsString.ToUpper(CultureInfo.CurrentCulture));
                                doChange = false;
                            }
                            else
                            {
                                result.Append(letterAsString.ToLower(CultureInfo.CurrentCulture));
                            }
                        }
                        else
                        {
                            result.Append(letterAsString);
                        }
                    }
                    return result.ToString();
                }
                // atomic version of the node
                var starNode = GetNode("<star/>");
                var recursiveStar = new Star(Query, Request, starNode);
                Template.InnerText = recursiveStar.ProcessChange();
                if (!string.IsNullOrEmpty(Template.InnerText)) continue;
                return string.Empty;
            }
        }
Example #4
0
 public void TestExpectedInputIndexSecond()
 {
     var testNode = StaticHelpers.GetNode("<star index=\"2\"/>");
     _tagHandler = new Star(_query, _request, testNode);
     Assert.AreEqual("first star", _tagHandler.ProcessChange());
 }
Example #5
0
 public void TestExpectedInput()
 {
     var testNode = StaticHelpers.GetNode("<star/>");
     _tagHandler = new Star(_query, _request, testNode);
     Assert.AreEqual("second star", _tagHandler.ProcessChange());
 }
Example #6
0
 public void TestBadInputTagName()
 {
     var testNode = StaticHelpers.GetNode("<stor index=\"1\"/>");
     _tagHandler = new Star(_query, _request, testNode);
     Assert.AreEqual("", _tagHandler.ProcessChange());
 }