Пример #1
0
        protected CompiledKnowledgeBase(SerializationInfo info, StreamingContext context)
        {
            this.synonyms            = (Dictionary <string, Synonym>)info.GetValue("s", typeof(Dictionary <string, Synonym>));
            this.replacements        = (List <Replacement>)info.GetValue("r", typeof(List <Replacement>));
            this.inputs              = (Dictionary <string, List <InputRecognizer> >)info.GetValue("i", typeof(Dictionary <string, List <InputRecognizer> >));
            this.outputs             = (Dictionary <string, List <Output> >)info.GetValue("o", typeof(Dictionary <string, List <Output> >));
            this.knowledgeBaseItem   = (KnowledgeBaseItem)info.GetValue("k", typeof(KnowledgeBaseItem));
            this.knowledgeBaseInfo   = (KnowledgeBaseInfo)info.GetValue("kbi", typeof(KnowledgeBaseInfo));
            this.build               = info.GetInt32("b");
            this.random              = new Random();
            this.recentOutputsByRule = new Dictionary <string, List <string> >();

            //use a try/catch block around any new vales
            try
            {
                this.inputReplacements = (List <InputReplacement>)info.GetValue("ir", typeof(List <InputReplacement>));
            }
            catch
            {
                this.inputReplacements = new List <InputReplacement>();
            }

            this.initializeCSToolbox();
            try
            {
                this.csToolbox.CodeModules = (List <CodeModule>)info.GetValue("cm", typeof(List <CodeModule>));
            }
            catch
            {
                this.csToolbox.CodeModules = new List <CodeModule>();
            }
        }
Пример #2
0
        public void ReloadKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            CompiledKnowledgeBase ckb = this.LoadKnowledgeBase(kb, knowledgeBaseItem);
            string stPath             = knowledgeBaseItem.Fullpath + knowledgeBaseItem.Filename;

            this.addOrReplaceCompiledKnowlegeBase(stPath, ckb);
        }
Пример #3
0
 public Reply(string text, string agentText, string cmd, string ruleId, double cf, KnowledgeBaseItem knowledgeBaseItem)
 {
     this.Text             = text;
     this.AgentText        = agentText;
     this.Cmd              = cmd;
     this.RuleId           = ruleId;
     this.ConfidenceFactor = cf;
     this.KBItem           = knowledgeBaseItem;
 }
Пример #4
0
        public CompiledKnowledgeBase LoadKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            CompiledKnowledgeBase ckb = new CompiledKnowledgeBase();

            ckb.Build                = kb.Build;
            ckb.Name                 = knowledgeBaseItem.Fullpath + knowledgeBaseItem.Filename;
            ckb.OnRuleCompiled      += new CompiledKnowledgeBase.RuleCompiled(this.compiledKnowledgeBase_OnRuleCompiled);
            ckb.OnRuleCompileFailed += new CompiledKnowledgeBase.RuleCompileFailed(this.compiledKnowledgeBase_OnRuleCompileFailed);
            ckb.OnCompileError      += new Conversive.DevBot5.CompiledKnowledgeBase.CompileError(ckb_OnCompileError);
            ckb.OnCompileWarning    += new Conversive.DevBot5.CompiledKnowledgeBase.CompileWarning(ckb_OnCompileWarning);
            ckb.LoadKnowledgeBase(kb, knowledgeBaseItem);
            return(ckb);
        }
Пример #5
0
 public CompiledKnowledgeBase()
 {
     this.synonyms          = new Dictionary <string, Synonym>();
     this.replacements      = new List <Replacement>();
     this.inputReplacements = new List <InputReplacement>();
     this.inputs            = new Dictionary <string, List <InputRecognizer> >();
     this.outputs           = new Dictionary <string, List <Output> >();
     this.knowledgeBaseItem = new KnowledgeBaseItem();
     this.knowledgeBaseInfo = new KnowledgeBaseInfo();
     this.build             = -1;
     this.Name   = "";
     this.random = new Random();
     this.recentOutputsByRule = new Dictionary <string, List <string> >();
     this.initializeCSToolbox();
 }
Пример #6
0
        public void LoadKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
        {
            this.knowledgeBaseItem = knowledgeBaseItem;
            this.knowledgeBaseInfo = kb.Info;
            this.LoadResourceFiles(kb.ResourceFiles);
            KnowledgeBase decompressedKB = kb.DecompressTemplates(knowledgeBaseItem.Fullpath);

            if (decompressedKB != null)
            {
                this.compileRules("_root", decompressedKB.Rules);
            }
            else
            {
                this.compileRules("_root", kb.Rules);
            }
            this.csToolbox.Compile();
        }
Пример #7
0
 public CompiledKnowledgeBase CompileKnowledgeBase(KnowledgeBase kb, KnowledgeBaseItem knowledgeBaseItem)
 {
     return(LoadKnowledgeBase(kb, knowledgeBaseItem));
 }