Пример #1
0
        private static string CleanToEnglish(string s0)
        {
            string sent2 = StaticAIMLUtils.ForOutputTemplate(s0);
            var    s     = StaticAIMLUtils.ToEnglish(sent2, null);

            s = StaticAIMLUtils.Trim(s).Trim(' ', ',', '-', ' ', ' ');
            return(s);
        }
Пример #2
0
        static public string MakeKey(string newStr, string newGuard, string newThat)
        {
            var    f  = AsStar(newStr) + " " + AsStar(newThat);
            string gs = AsStar(newGuard);

            if (gs != "*")
            {
                return(StaticAIMLUtils.MakeAimlMatchable(f));
            }
            return(StaticAIMLUtils.MakeAimlMatchable(f + " guardbom " + gs));
        }
Пример #3
0
        public static string ToTemplateXML(XmlNode templateNode)
        {
            string requestName = ToXmlValue(templateNode);

            if (templateNode.NodeType != XmlNodeType.Element)
            {
                string sentence = VisibleRendering(StaticAIMLUtils.getTemplateNode(requestName).ChildNodes,
                                                   PatternSideRendering);
                requestName = "<template>" + sentence + "</template>";
            }
            return(requestName);
        }
Пример #4
0
 private void DoSideEffect(string effectName, ThreadStart action)
 {
     if (ShouldCommit)
     {
         StaticAIMLUtils.writeDebugLine("Commiting Sidefffect " + effectName);
         action();
     }
     else
     {
         StaticAIMLUtils.writeDebugLine("Skipping Sidefffect " + effectName);
     }
 }
Пример #5
0
        private string ToString(string pre, ICollection c)
        {
            if (c == null || c.Count == 0)
            {
                return(Environment.NewLine);
            }
            string s = "";

            foreach (object node in c)
            {
                s += pre + (string)StaticAIMLUtils.CleanWhitepaces("" + node) + Environment.NewLine;
            }
            s += Environment.NewLine;
            return(s);
        }
Пример #6
0
 public static string CleanWhitepacesObject(object info)
 {
     if (info is XmlNode)
     {
         XmlNode n = (XmlNode)info;
         if (n.Name == "template")
         {
             info = n.ParentNode;
         }
     }
     if (info is TemplateInfo)
     {
         info = ((TemplateInfo)info).CategoryInfo;
     }
     return(StaticAIMLUtils.CleanWhitepaces("" + info));
 }
Пример #7
0
        private static string Fudge(string expectedAnswer)
        {
            expectedAnswer = StaticAIMLUtils.CleanPunct(CleanWhitepaces(expectedAnswer));
            expectedAnswer = expectedAnswer.Replace("<html:", "<");
            expectedAnswer = expectedAnswer.Replace(" />", "/>");
            string was = expectedAnswer;

            expectedAnswer = expectedAnswer.Replace("<br xmlns:html=\"http://www.w3.org/1999/xhtml\"/>", " ");
            expectedAnswer = expectedAnswer.Replace("<br/>", " ");
            if (was != expectedAnswer)
            {
                expectedAnswer = expectedAnswer.Replace(".", " ");
                return(CleanWhitepaces(expectedAnswer));
            }
            expectedAnswer = expectedAnswer.Replace(".", " ");
            return(CleanWhitepaces(expectedAnswer));
        }
Пример #8
0
        public bool Equals(SubQuery other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (!EqualsMeaning(other))
            {
                return(false);
            }
            bool same = //Equals(other.ov_TargetBot, ov_TargetBot)
                        //  && Equals(other.CurrentTemplate, CurrentTemplate)
                        //  && Equals(other.LastTagHandler, LastTagHandler)
                        //Equals(other.Pattern, Pattern)
                        //  && Equals(other.prefix, prefix)
                        Equals(other.Request, Request) &&
                        Equals(other.Result, Result)
                        //  && Equals(other.TopLevel, TopLevel)
                        && StaticAIMLUtils.CollectionEquals(other.GuardStar, GuardStar) &&
                        StaticAIMLUtils.CollectionEquals(other.InputStars, InputStars) &&
                        StaticAIMLUtils.CollectionEquals(other.ThatStars, ThatStars) &&
                        StaticAIMLUtils.CollectionEquals(other.TopicStar, TopicStar) &&
                        StaticAIMLUtils.SetsEquals(other.Flags, Flags)
                        //  && other.HasFailed == HasFailed
                        //  && other.HasSuceeded == HasSuceeded
                        //  && other.GetDictValue == GetDictValue
                        //  && other.SetDictValue == SetDictValue
                        //  && other.IsTraced.Equals(IsTraced)
                        //  && SetsEquals(other.Templates, Templates)
                        //  && Equals(other.Graph, Graph)
            ;

            if (!same)
            {
                return(true);

                return(false);
            }
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            return(same);
            // ReSharper restore ConditionIsAlwaysTrueOrFalse
        }
Пример #9
0
        public int CompareTo(SubQuery other)
        {
            if (Pattern == null)
            {
                return(StaticAIMLUtils.ReferenceCompare(this, other));
            }
            int compare = Pattern.CompareTo(other.Pattern);

            if (compare != 0)
            {
                return(compare);
            }
            compare = StaticAIMLUtils.CollectionCompare(Templates, other.Templates, TemplateInfoImpl.CompareTemplates);
            if (compare != 0)
            {
                return(compare);
            }
            return(StaticAIMLUtils.ReferenceCompare(this, other));
        }
Пример #10
0
        public static string TryGetPrecondionThat(string tagName, XmlNode extractedXML, out bool isRequired, out string indexVal, out bool indexPosition1)
        {
            isRequired     = extractedXML != null && extractedXML.LocalName == tagName;
            indexVal       = StaticAIMLUtils.GetAttribValue(extractedXML, "index", "1,1");
            indexPosition1 = indexVal == "1" || indexVal == "1,1" || indexVal == "1,*";
            if (!isRequired)
            {
                return(null);
            }
            string patternTxt = StaticAIMLUtils.VisibleRendering(extractedXML.ChildNodes, StaticAIMLUtils.PatternSideRendering);

            if (patternTxt == "")
            {
                patternTxt = StaticAIMLUtils.GetAttribValue(extractedXML, "value," + tagName + ",match,name", null);
            }
            isRequired = false;
            foreach (XmlNode childs in extractedXML.ChildNodes)
            {
                if (childs.NodeType != XmlNodeType.Comment)
                {
                    isRequired = true;
                    break;
                }
            }
            if (!isRequired)
            {
                if (patternTxt == null)
                {
                    //writeToLog("extractThat1: '" + patternTxt + "' from " + extractedXML.OuterXml);
                }
                else
                {
                    isRequired = true;
                }
            }
            return(patternTxt);
        }
Пример #11
0
        public bool AimlSameKey(string newStr, string newGuard, string newThat)
        {
            if (_templateKey != null)
            {
                return(_templateKey == MakeKey(newStr, newGuard, newThat));
            }
            if (!StaticAIMLUtils.AimlSame(makeStar(Guard.PatternNode), AsStar(newGuard)))
            {
                return(false);
            }
            if (!StaticAIMLUtils.AimlSame(makeStar(TemplateXml), AsStar(newStr)))
            {
                return(false);
            }
            return(true);

            /*
             *
             * return MakeKey(oldStr, oldGuard, oldThat);
             * return StaticAIMLUtils.AimlSame(newStr, Output.OuterXml)
             *     && StaticAIMLUtils.AimlSame(newGuard, oldGuard)
             *     && StaticAIMLUtils.AimlSame(newThat, oldThat);
             */
        }
 public static string InnerXmlText(XmlNode node)
 {
     return(StaticAIMLUtils.InnerXmlText(node));
 }
 internal static bool IsTrueOrYes(string str)
 {
     return(StaticAIMLUtils.IsTrueOrYes(str));
 }
 public static string Trim(string unifiable)
 {
     return(StaticAIMLUtils.Trim(unifiable));
 }
 public static bool IsUnknown(object unifiable)
 {
     return(StaticAIMLUtils.IsUnknown(unifiable));
 }
 public static bool DifferentBesidesCase(string s1, string s2)
 {
     return(StaticAIMLUtils.DifferentBesidesCase(s1, s2));
 }
 public static string ToUpper(string unifiable)
 {
     return(StaticAIMLUtils.ToUpper(unifiable));
 }
 public static bool IsFalse(Unifiable unifiable)
 {
     return(StaticAIMLUtils.IsFalse(unifiable));
 }
Пример #19
0
 internal static string ForOutputTemplate(string sentenceIn)
 {
     return(VisibleRendering(StaticAIMLUtils.getTemplateNode(sentenceIn).ChildNodes, TemplateSideRendering));
 }
 public static bool IsEMPTY(Object unifiable)
 {
     return(StaticAIMLUtils.IsEMPTY(unifiable));
 }
 public static bool IsMissing(Object unifiable)
 {
     return(StaticAIMLUtils.IsMissing(unifiable));
 }
Пример #22
0
        virtual public string ToFileString(PrintOptions printOptions)
        {
            //if (XmlDocumentLineInfo.SkipXmlns && this.srcNode.Attributes != null) this.srcNode.Attributes.RemoveNamedItem("xmlns");
            string s = "";

            if (IsDisabled)
            {
                if (!printOptions.WriteDisabledItems)
                {
                    return(s);
                }
            }
            string graphName = ((IAIMLInfo)this).Graph.ScriptingName;

            if (printOptions.IncludeGraphName)
            {
                if (graphName != printOptions.CurrentGraphName)
                {
                    if (printOptions.InsideAiml)
                    {
                        s += "\n</aiml>\n";
                        s += string.Format("\n<aiml graph=\"{0}\">\n", graphName);
                        printOptions.CurrentGraphName = graphName;
                    }
                    else
                    {
                        printOptions.InsideAiml = true;
                        s += string.Format("\n<aiml graph=\"{0}\">\n", graphName);
                        printOptions.CurrentGraphName = graphName;
                    }
                }
            }

            s += GetSourceWithTopic(printOptions);

            string escapedStuff = "";

            //if (!printOptions.IncludeLineInfoExternal)
            {
                if (!printOptions.GroupFileElements)
                {
                    if (printOptions.IncludeFileNamePerNode)
                    {
                        string cfile = Filename ?? StaticXMLUtils.FileNameOfXmlNode(srcNode);
                        if (cfile != printOptions.InsideFilename)
                        {
                            escapedStuff += cfile;
                            printOptions.InsideFilename = cfile;
                        }
                    }
                }
                if (printOptions.IncludeLinenoPerNode)
                {
                    escapedStuff += ":" + LineNumberInfo;
                }
            }

            escapedStuff = StaticXMLUtils.MakeXmlCommentSafe(escapedStuff);
            if (IsDisabled)
            {
                s = DLRConsole.SafeFormat("<!-- {0} {1} {2} -->", StaticAIMLUtils.MakeXmlCommentSafe(WhyDisabled), StaticAIMLUtils.MakeXmlCommentSafe(s), escapedStuff);
            }
            else
            {
                s = DLRConsole.SafeFormat("{0} <!-- {1}  -->", s, escapedStuff);
            }
            return(s);
        }
 public static string SafeFormat(string f, params object[] args)
 {
     return(StaticAIMLUtils.SafeFormat(f, args));
 }
 public static bool IsSomething(Unifiable s, out Unifiable something)
 {
     return(StaticAIMLUtils.IsSomething(s, out something));
 }
 public static bool IsFalseOrNo(string str)
 {
     return(StaticAIMLUtils.IsFalseOrNo(str));
 }
 public static bool IsNullOrEmpty(Object unifiable)
 {
     return(StaticAIMLUtils.IsNullOrEmpty(unifiable));
 }
Пример #27
0
 public static int CompareTemplates(TemplateInfo thiz, TemplateInfo other)
 {
     return(StaticAIMLUtils.CollectionCompare <XmlNode>(thiz.TemplateXml.ChildNodes, other.TemplateXml.ChildNodes, StaticAIMLUtils.CompareXmlNodes));
 }
 public static bool IsIncomplete(Object unifiable)
 {
     return(StaticAIMLUtils.IsIncomplete(unifiable));
 }
 public static void writeDebugLine(string f, params object[] args)
 {
     StaticAIMLUtils.writeDebugLine(f, args);
 }
 public static string ReTrimAndspace(string s)
 {
     return(StaticAIMLUtils.ReTrimAndspace(s));
 }