public WissensCategory(Normalisierung normalisierung, XmlNode categoryNode, string themaName, string aimlDateiName, GaitoBotEigenschaften botEigenschaften)
        {
            this._categoryNode  = categoryNode;
            this._aimlDateiName = aimlDateiName;
            this._themaName     = themaName;
            XmlNode xmlNode = this._categoryNode.SelectSingleNode("pattern");

            if (xmlNode != null)
            {
                this._pattern = new MatchString(MatchString.GetInhaltFromXmlNode(xmlNode, normalisierung, botEigenschaften));
            }
            else
            {
                this._pattern = new MatchString("*");
            }
            XmlNode xmlNode2 = this._categoryNode.SelectSingleNode("that");

            if (xmlNode2 != null)
            {
                this._that = new MatchString(MatchString.GetInhaltFromXmlNode(xmlNode2, normalisierung, botEigenschaften));
            }
            else
            {
                this._that = new MatchString("*");
            }
            this.ErmittleObSRAICategory();
        }
예제 #2
0
 public GaitoBotInterpreter(CultureInfo loggingKultur, StartupInfos startupInfos)
 {
     this._wissen           = new Wissen();
     this._botEigenschaften = startupInfos.BotEigenschaften;
     this._loggingKultur    = loggingKultur;
     this._normalisierung   = new Normalisierung(startupInfos);
     this._ladeProtokoll    = new StringBuilder();
 }
예제 #3
0
 public WissensLader(Wissen wissen, CultureInfo protokollKultur, Normalisierung normalisierung)
 {
     this._wissen          = wissen;
     this._protokollKultur = protokollKultur;
     this._normalisierung  = normalisierung;
     this._protokoll       = new StringBuilder();
     this._protokoll.AppendFormat(ResReader.Reader(this._protokollKultur).GetString("WissensLadenGestartetUm", this._protokollKultur), (object)DateTime.Now.ToString());
     this._protokoll.Append("\n");
 }
예제 #4
0
 public AntwortFinder(string[] trenner, Normalisierung normalisierer, Wissen wissen, GaitoBotSession session, GaitoBotEigenschaften botEigenschaften, bool beiEinwortEingabenOhneMatchAufSraiOnlyOneWordUmleiten)
 {
     this._beiEinwortEingabenOhneMatchAufSraiOnlyOneWordUmleiten = beiEinwortEingabenOhneMatchAufSraiOnlyOneWordUmleiten;
     this._trenner          = trenner;
     this._botEigenschaften = botEigenschaften;
     this._wissen           = wissen;
     this._session          = session;
     this._normalisierer    = normalisierer;
 }
예제 #5
0
        public static string GetInhaltFromXmlNode(
            XmlNode inhaltNode,
            Normalisierung normalisierung,
            GaitoBotEigenschaften botEigenschaften)
        {
            StringBuilder stringBuilder1 = new StringBuilder();

            stringBuilder1.AppendFormat(" ");
            if (!inhaltNode.HasChildNodes)
            {
                stringBuilder1.Append(inhaltNode.Value);
            }
            else
            {
                foreach (XmlNode childNode in inhaltNode.ChildNodes)
                {
                    if (childNode is XmlText)
                    {
                        stringBuilder1.Append(childNode.InnerText);
                    }
                    else
                    {
                        if (!(childNode is XmlElement))
                        {
                            throw new ApplicationException(string.Format("Unbekannter XMLTyp '{0}' in Pattern '{1}'", (object)childNode.OuterXml, (object)inhaltNode.OuterXml));
                        }
                        if (childNode.Name == "bot")
                        {
                            if (childNode.Attributes["name"] != null)
                            {
                                string name = childNode.Attributes["name"].Value;
                                stringBuilder1.Append(botEigenschaften.Lesen(name));
                            }
                            else
                            {
                                stringBuilder1.Append("BOT_UNKNOWN");
                            }
                        }
                        else
                        {
                            stringBuilder1.AppendFormat("[[Unbekanntes Tag '{0}' in Pattern '{1}']]", (object)childNode.OuterXml, (object)inhaltNode.OuterXml);
                        }
                    }
                }
            }
            stringBuilder1.AppendFormat(" ");
            string eingabe = stringBuilder1.ToString();

            string[]      strArray       = normalisierung.StandardErsetzungenDurchfuehren(eingabe).Split(" \r\n\t".ToCharArray());
            StringBuilder stringBuilder2 = new StringBuilder();

            foreach (string rohEingabe in strArray)
            {
                string str = !(rohEingabe == "*") && !(rohEingabe == "_") ? Normalisierung.EingabePatternOptimieren(rohEingabe, false) : rohEingabe;
                if (stringBuilder2.Length == 0)
                {
                    stringBuilder2.Append(str);
                }
                else
                {
                    stringBuilder2.AppendFormat(" {0}", (object)str);
                }
            }
            return(stringBuilder2.ToString());
        }
예제 #6
0
        private AntwortSatz GetQualifizierteAntwort_(string einSatz, string that, ArrayList vorherigeSRAIs)
        {
            this._session.Denkprotokoll.Add(new BotDenkProtokollSchritt(einSatz, BotDenkProtokollSchritt.SchrittArten.Eingabe));
            if (vorherigeSRAIs.Count > 50)
            {
                return(new AntwortSatz(string.Format("SRAI-recursion at '{0}'", einSatz), false));
            }
            einSatz = this._normalisierer.StandardErsetzungenDurchfuehren(einSatz);
            einSatz = Normalisierung.EingabePatternOptimieren(einSatz, false).Trim();
            if (einSatz == "")
            {
                this._session.Denkprotokoll.Add(new BotDenkProtokollSchritt("Die Eingabe ist nach Normalisierung und Patternoptimierung leer", BotDenkProtokollSchritt.SchrittArten.Info));
                return(null);
            }
            string text = that;

            that = this._normalisierer.StandardErsetzungenDurchfuehren(that);
            if (that == "")
            {
                that = text;
            }
            else
            {
                text = that;
            }
            that = Normalisierung.EingabePatternOptimieren(that.Trim(), false);
            if (that == "")
            {
                that = text;
            }
            WissenThema thema  = this._wissen.GetThema(this._session.AktuellesThema);
            AntwortSatz result = default(AntwortSatz);

            if (thema != null)
            {
                foreach (WissensCategory category in thema.Categories)
                {
                    if (category.Pattern.Inhalt != "*" && category.That.Inhalt != "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out result))
                    {
                        return(result);
                    }
                }
            }
            thema = this._wissen.GetThema(this._session.AktuellesThema);
            if (thema != null)
            {
                foreach (WissensCategory category2 in thema.Categories)
                {
                    if (category2.Pattern.Inhalt != "*" && category2.That.Inhalt == "*" && this.PasstCategory(category2, einSatz, that, vorherigeSRAIs, out result))
                    {
                        return(result);
                    }
                }
            }
            for (int i = 1; i < this._session.LetzteThemen.Count; i++)
            {
                string themaName = this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - i];
                thema = this._wissen.GetThema(themaName);
                if (thema != null)
                {
                    foreach (WissensCategory category3 in thema.Categories)
                    {
                        if (category3.IstSrai && category3.Pattern.Inhalt != "*" && category3.That.Inhalt != "*" && this.PasstCategory(category3, einSatz, that, vorherigeSRAIs, out result))
                        {
                            return(result);
                        }
                    }
                }
            }
            for (int i = 1; i < this._session.LetzteThemen.Count; i++)
            {
                string themaName = this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - i];
                thema = this._wissen.GetThema(themaName);
                if (thema != null)
                {
                    foreach (WissensCategory category4 in thema.Categories)
                    {
                        if (category4.IstSrai && category4.Pattern.Inhalt != "*" && category4.That.Inhalt == "*" && this.PasstCategory(category4, einSatz, that, vorherigeSRAIs, out result))
                        {
                            return(result);
                        }
                    }
                }
            }
            thema = this._wissen.GetThema(this._session.AktuellesThema);
            if (thema != null)
            {
                foreach (WissensCategory starCategory in thema.StarCategories)
                {
                    if (starCategory.That.Inhalt != "*" && this.PasstCategory(starCategory, einSatz, that, vorherigeSRAIs, out result))
                    {
                        return(result);
                    }
                }
            }
            for (int i = 1; i < this._session.LetzteThemen.Count; i++)
            {
                string themaName = this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - i];
                thema = this._wissen.GetThema(themaName);
                if (thema != null)
                {
                    foreach (WissensCategory category5 in thema.Categories)
                    {
                        if (category5.That.Inhalt != "*" && this.PasstCategory(category5, einSatz, that, vorherigeSRAIs, out result))
                        {
                            return(result);
                        }
                    }
                }
            }
            thema = this._wissen.GetThema(this._session.AktuellesThema);
            if (thema != null)
            {
                foreach (WissensCategory starCategory2 in thema.StarCategories)
                {
                    if (starCategory2.That.Inhalt == "*" && this.PasstCategory(starCategory2, einSatz, that, vorherigeSRAIs, out result))
                    {
                        return(result);
                    }
                }
            }
            for (int i = 1; i < this._session.LetzteThemen.Count; i++)
            {
                string themaName = this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - i];
                thema = this._wissen.GetThema(themaName);
                if (thema != null)
                {
                    foreach (WissensCategory category6 in thema.Categories)
                    {
                        if (category6.That.Inhalt == "*" && this.PasstCategory(category6, einSatz, that, vorherigeSRAIs, out result))
                        {
                            return(result);
                        }
                    }
                }
            }
            return(null);
        }
예제 #7
0
        private AntwortSatz GetQualifizierteAntwort_(
            string einSatz,
            string that,
            ArrayList vorherigeSRAIs)
        {
            this._session.Denkprotokoll.Add(new BotDenkProtokollSchritt(einSatz, BotDenkProtokollSchritt.SchrittArten.Eingabe));
            if (vorherigeSRAIs.Count > 50)
            {
                return(new AntwortSatz(string.Format("SRAI-recursion at '{0}'", (object)einSatz), false));
            }
            einSatz = this._normalisierer.StandardErsetzungenDurchfuehren(einSatz);
            einSatz = Normalisierung.EingabePatternOptimieren(einSatz, false).Trim();
            if (einSatz == "")
            {
                this._session.Denkprotokoll.Add(new BotDenkProtokollSchritt("Die Eingabe ist nach Normalisierung und Patternoptimierung leer", BotDenkProtokollSchritt.SchrittArten.Info));
                return((AntwortSatz)null);
            }
            string str = that;

            that = this._normalisierer.StandardErsetzungenDurchfuehren(that);
            if (that == "")
            {
                that = str;
            }
            else
            {
                str = that;
            }
            that = Normalisierung.EingabePatternOptimieren(that.Trim(), false);
            if (that == "")
            {
                that = str;
            }
            WissenThema thema1 = this._wissen.GetThema(this._session.AktuellesThema);
            AntwortSatz antwort;

            if (thema1 != null)
            {
                foreach (WissensCategory category in thema1.Categories)
                {
                    if (category.Pattern.Inhalt != "*" && category.That.Inhalt != "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                    {
                        return(antwort);
                    }
                }
            }
            WissenThema thema2 = this._wissen.GetThema(this._session.AktuellesThema);

            if (thema2 != null)
            {
                foreach (WissensCategory category in thema2.Categories)
                {
                    if (category.Pattern.Inhalt != "*" && category.That.Inhalt == "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                    {
                        return(antwort);
                    }
                }
            }
            for (int index = 1; index < this._session.LetzteThemen.Count; ++index)
            {
                WissenThema thema3 = this._wissen.GetThema(this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - index]);
                if (thema3 != null)
                {
                    foreach (WissensCategory category in thema3.Categories)
                    {
                        if (category.IstSrai && category.Pattern.Inhalt != "*" && category.That.Inhalt != "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                        {
                            return(antwort);
                        }
                    }
                }
            }
            for (int index = 1; index < this._session.LetzteThemen.Count; ++index)
            {
                WissenThema thema3 = this._wissen.GetThema(this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - index]);
                if (thema3 != null)
                {
                    foreach (WissensCategory category in thema3.Categories)
                    {
                        if (category.IstSrai && category.Pattern.Inhalt != "*" && category.That.Inhalt == "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                        {
                            return(antwort);
                        }
                    }
                }
            }
            WissenThema thema4 = this._wissen.GetThema(this._session.AktuellesThema);

            if (thema4 != null)
            {
                foreach (WissensCategory starCategory in thema4.StarCategories)
                {
                    if (starCategory.That.Inhalt != "*" && this.PasstCategory(starCategory, einSatz, that, vorherigeSRAIs, out antwort))
                    {
                        return(antwort);
                    }
                }
            }
            for (int index = 1; index < this._session.LetzteThemen.Count; ++index)
            {
                WissenThema thema3 = this._wissen.GetThema(this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - index]);
                if (thema3 != null)
                {
                    foreach (WissensCategory category in thema3.Categories)
                    {
                        if (category.That.Inhalt != "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                        {
                            return(antwort);
                        }
                    }
                }
            }
            WissenThema thema5 = this._wissen.GetThema(this._session.AktuellesThema);

            if (thema5 != null)
            {
                foreach (WissensCategory starCategory in thema5.StarCategories)
                {
                    if (starCategory.That.Inhalt == "*" && this.PasstCategory(starCategory, einSatz, that, vorherigeSRAIs, out antwort))
                    {
                        return(antwort);
                    }
                }
            }
            for (int index = 1; index < this._session.LetzteThemen.Count; ++index)
            {
                WissenThema thema3 = this._wissen.GetThema(this._session.LetzteThemen[this._session.LetzteThemen.Count - 1 - index]);
                if (thema3 != null)
                {
                    foreach (WissensCategory category in thema3.Categories)
                    {
                        if (category.That.Inhalt == "*" && this.PasstCategory(category, einSatz, that, vorherigeSRAIs, out antwort))
                        {
                            return(antwort);
                        }
                    }
                }
            }
            return((AntwortSatz)null);
        }
예제 #8
0
        public static string GetInhaltFromXmlNode(XmlNode inhaltNode, Normalisierung normalisierung, GaitoBotEigenschaften botEigenschaften)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat(" ");
            if (!inhaltNode.HasChildNodes)
            {
                stringBuilder.Append(inhaltNode.Value);
            }
            else
            {
                foreach (XmlNode childNode in inhaltNode.ChildNodes)
                {
                    if (childNode is XmlText)
                    {
                        stringBuilder.Append(childNode.InnerText);
                        continue;
                    }
                    if (childNode is XmlElement)
                    {
                        if (childNode.Name == "bot")
                        {
                            if (childNode.Attributes["name"] != null)
                            {
                                string value = childNode.Attributes["name"].Value;
                                stringBuilder.Append(botEigenschaften.Lesen(value));
                            }
                            else
                            {
                                stringBuilder.Append("BOT_UNKNOWN");
                            }
                        }
                        else
                        {
                            stringBuilder.AppendFormat("[[Unbekanntes Tag '{0}' in Pattern '{1}']]", childNode.OuterXml, inhaltNode.OuterXml);
                        }
                        continue;
                    }
                    throw new ApplicationException(string.Format("Unbekannter XMLTyp '{0}' in Pattern '{1}'", childNode.OuterXml, inhaltNode.OuterXml));
                }
            }
            stringBuilder.AppendFormat(" ");
            string eingabe = stringBuilder.ToString();

            eingabe = normalisierung.StandardErsetzungenDurchfuehren(eingabe);
            string[] array = eingabe.Split(" \r\n\t".ToCharArray());
            stringBuilder = new StringBuilder();
            string[] array2 = array;
            foreach (string text in array2)
            {
                string text2 = (!(text == "*") && !(text == "_")) ? Normalisierung.EingabePatternOptimieren(text, false) : text;
                if (stringBuilder.Length == 0)
                {
                    stringBuilder.Append(text2);
                }
                else
                {
                    stringBuilder.AppendFormat(" {0}", text2);
                }
            }
            return(stringBuilder.ToString());
        }