protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "gender") { if (TemplateNode.InnerText.Length > 0) { // non atomic version of the node return(Normalize.ApplySubstitutions.Substitute(Bot, Bot.GenderSubstitutions, TemplateNode.InnerText)); } else { // atomic version of the node XmlNode starNode = GetNode("<star/>"); Star recursiveStar = new Star(Bot, User, Query, Request, Result, starNode); TemplateNode.InnerText = recursiveStar.Transform(); if (TemplateNode.InnerText.Length > 0) { return(ProcessChange()); } else { return(string.Empty); } } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "sentence") { if (TemplateNode.InnerText.Length > 0) { StringBuilder result = new StringBuilder(); char[] letters = TemplateNode.InnerText.Trim().ToCharArray(); bool doChange = true; for (int i = 0; i < letters.Length; i++) { string letterAsString = Convert.ToString(letters[i]); if (Bot.Splitters.Contains(letterAsString)) { doChange = true; } Regex lowercaseLetter = new Regex("[a-zA-Z]"); if (lowercaseLetter.IsMatch(letterAsString)) { if (doChange) { result.Append(letterAsString.ToUpper(Bot.Locale)); doChange = false; } else { result.Append(letterAsString.ToLower(Bot.Locale)); } } else { result.Append(letterAsString); } } return(result.ToString()); } else { // atomic version of the node XmlNode starNode = GetNode("<star/>"); Star recursiveStar = new Star(Bot, User, Query, Request, Result, starNode); TemplateNode.InnerText = recursiveStar.Transform(); if (TemplateNode.InnerText.Length > 0) { return(ProcessChange()); } else { return(string.Empty); } } } return(string.Empty); }
protected override string ProcessChange() { if (TemplateNode.Name.ToLower() == "sr") { XmlNode starNode = GetNode("<star/>"); Star recursiveStar = new Star(Bot, User, Query, Request, Result, starNode); string starContent = recursiveStar.Transform(); XmlNode sraiNode = GetNode("<srai>" + starContent + "</srai>"); Srai sraiHandler = new Srai(Bot, User, Query, Request, Result, sraiNode); return(sraiHandler.Transform()); } return(string.Empty); }