Beispiel #1
0
 public override float CanUnify(Unifiable with)
 {
     if (templateNode.NodeType == XmlNodeType.Text)
     {
         string srch = (" " + with.ToValue(query) + " ").ToUpper();
         return(((" " + templateNode.InnerText + " ").ToUpper().Contains(srch)) ? AND_TRUE : AND_FALSE);
     }
     if (templateNode.HasChildNodes)
     {
         // recursively check
         foreach (XmlNode childNode in templateNode.ChildNodes)
         {
             try
             {
                 if (childNode.NodeType == XmlNodeType.Text)
                 {
                     string srch = (" " + with.ToValue(query) + " ").ToUpper();
                     return(((" " + childNode.InnerText + " ").ToUpper().Contains(srch)) ? AND_TRUE : AND_FALSE);
                 }
                 AIMLTagHandler part = GetChildTagHandler(childNode);
                 if (part.CallCanUnify(with) > 0)
                 {
                     return(AND_FALSE);
                 }
             }
             catch (Exception e)
             {
                 Proc.writeToLog(e);
                 writeToLogWarn("" + e);
             }
         }
         return(AND_TRUE);
     }
     return(AND_TRUE);
 }
Beispiel #2
0
 public override float CanUnify(Unifiable with)
 {
     if (templateNode.NodeType == XmlNodeType.Text)
     {
         string srch = ToUpper(" " + with.ToValue(query) + " ");
         return((ToUpper(" " + templateNode.InnerText + " ").Equals(srch)) ? STAR_TRUE : STAR_FALSE);
     }
     if (templateNode.HasChildNodes)
     {
         {
             Unifiable rest = with;
             // recursively check
             foreach (XmlNode childNode in templateNode.ChildNodes)
             {
                 with = rest.First;
                 rest = rest.Rest;
                 try
                 {
                     if (childNode.NodeType == XmlNodeType.Text)
                     {
                         string srch = ToUpper(" " + with.ToValue(query) + " ");
                         return((ToUpper(" " + templateNode.InnerText + " ").Equals(srch))
                                    ? STAR_TRUE
                                    : STAR_FALSE);
                     }
                     AIMLTagHandler part = GetChildTagHandler(childNode);
                     if (part.CallCanUnify(with) > 0)
                     {
                         return(STAR_FALSE);
                     }
                 }
                 catch (Exception e)
                 {
                     AltBot.writeDebugLine("" + e);
                 }
             }
             return(IsNullOrEmpty(rest) ? STAR_TRUE : STAR_FALSE);
         }
     }
     return(IsNullOrEmpty(with) ? STAR_TRUE : STAR_FALSE);
 }
Beispiel #3
0
        public override float CanUnify(Unifiable with)
        {
            string srch = with.ToValue(query);

            if (templateNode.NodeType == XmlNodeType.Text)
            {
                bool unifyWithTextNode = UnifyWithTextNode(templateNode, srch);
                return(unifyWithTextNode ? AND_TRUE : AND_FALSE);
            }
            if (templateNode.HasChildNodes)
            {
                // recursively check
                foreach (XmlNode childNode in templateNode.ChildNodes)
                {
                    try
                    {
                        if (childNode.NodeType == XmlNodeType.Text)
                        {
                            return(UnifyWithTextNode(childNode, srch) ? AND_TRUE : AND_FALSE);
                        }
                        AIMLTagHandler part = GetChildTagHandler(childNode);
                        if (part.CallCanUnify(with) > 0)
                        {
                            return(AND_FALSE);
                        }
                    }
                    catch (Exception e)
                    {
                        Proc.writeToLog(e);
                        writeToLogWarn("" + e);
                    }
                }
                return(AND_TRUE);
            }
            return(AND_TRUE);
        }