Esempio n. 1
0
        public static void PrintResult(Result result, OutputDelegate console, PrintOptions printOptions)
        {
            console("-----------------------------------------------------------------");
            console("Result: " + result.Graph + " Request: " + result.request);
            foreach (Unifiable s in result.InputSentences)
            {
                console("input: \"" + s + "\"");
            }
            PrintTemplates(result.ResultTemplates, console, printOptions, TimeSpan.Zero);
            foreach (SubQuery s in result.SubQueries)
            {
                console("\n" + s);
            }
            console("-");
            var OutputSentences = result.OutputSentences;

            lock (OutputSentences)
            {
                foreach (string s in OutputSentences)
                {
                    console("outputsentence: " + s);
                }
            }
            console("-----------------------------------------------------------------");
        }
Esempio n. 2
0
 override public string ToFileString(PrintOptions printOptions)
 {
     if (CategoryInfo != null)
     {
         return(base.ToFileString(printOptions));
     }
     return(base.ToFileString(printOptions));
 }
Esempio n. 3
0
        public static string GetTemplateSource(IEnumerable CI, PrintOptions printOptions)
        {
            if (CI == null)
            {
                return("");
            }
            StringWriter fs = new StringWriter();

            GraphMaster.PrintToWriter(CI, printOptions, fs, null, TimeSpan.Zero);
            return(fs.ToString());
        }
Esempio n. 4
0
        private string GetCategoryXML(PrintOptions printOptions)
        {
            if (_srcNode != null)
            {
                return(printOptions.FormatXML(CategoryXml));
            }
            string thatStr = "", scoreStr = "";

            if (That != null && !That.IsCatchAll)
            {
                thatStr = String.Format("<that>{0}</that>", That);
            }
            double templateTemplateRating = Template.TemplateRating;

            if (templateTemplateRating != 1.0)
            {
                scoreStr = string.Format(" score=\"{0}\"", templateTemplateRating);
            }
            return(String.Format("<category><pattern>{0}</pattern>{1}<template{2}>{3}</template></category>", Pattern,
                                 thatStr, scoreStr, Response));
        }
Esempio n. 5
0
        public string GetSourceWithTopic(PrintOptions printOptions)
        {
            string s = "";
            //XmlNode topic1 = this.TopicXml;
            string insideTopic = printOptions.InsideTopic;
            string thisTopic   = Topic ?? insideTopic;
            //thisTopic = StaticXMLUtils.GetAttribValue(topic1, "name,topic", () => thisTopic, null);
            bool hasTopic = (thisTopic != insideTopic);

            if (hasTopic)
            {
                s += "<topic name=\"";
                s += thisTopic;
                s += "\">";
            }
            else if (Topic != null && !Topic.IsCatchAll)
            {
                hasTopic = true;
                s       += "<topic name=\"";
                string n = (string)Topic.FullPath;
                s += n;
                s += "\">";
            }

            s += GetCategoryXML(printOptions);
            if (printOptions.IncludeRuleComments)
            {
                s += GetRuleStrings;
            }

            if (hasTopic)
            {
                s += "</topic>";
            }
            printOptions.InsideTopic = insideTopic;
            return(s);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public static void PrintTemplates(IEnumerable CI, OutputDelegate console, PrintOptions printOptions, TimeSpan sleepBetween)
 {
     GraphMaster.PrintToWriter(CI, printOptions, new OutputDelegateWriter(console), null, sleepBetween);
 }