private void init()
 {
     cc          = new ChatController();
     cc.info     = IOController.getInfoFromJson("chatbotInfo.json");
     cc.concepts = IOController.getConceptsFromJson("chatbotConcepts.json");
     if (cc.concepts == null)
     {
         cc.concepts = new List <ConceptUnit>();
     }
     if (cc.info == null)
     {
         cc.info = new ChatInfo();
     }
     cc.outputEvent = new ChatController.sendChatMessageDelegate(printOutput);
     cc.specials    = IOController.readSpecialAnswerFromFile("special.txt");
     cc.start();
 }
Exemple #2
0
        private void dealInput(string str)
        {
            //try
            //{
            string ltpres = WebConnection.getResultFromLtp(str);

            ltpres = ltpres.Replace("\n", "").Replace('\\', ' ').Replace(" ", "").Replace("[[[", "[").Replace("]]]", "]");
            List <LtpWord> words = IOController.DeserializeJsonToList <LtpWord>(ltpres);

            getConcepts(words);
            meaningAnalysis(str);
            IOController.saveInfoAsJson("chatbotInfo.json", this.info);
            IOController.saveConceptsAsJson("chatbotConcepts.json", this.concepts);
            //}
            //catch(Exception e)
            //{
            //    tmpOutputSentence.Add("(程序异常)" + e.Message);
            //}
        }
Exemple #3
0
        public ChatController(sendChatMessageDelegate toutputEvent = null)
        {
            info = new ChatInfo();
            run  = false;

            nowWaitTime       = 0;
            nowWaitAllTime    = 0;
            tmpInputSentence  = new List <string>();
            tmpOutputSentence = new List <string>();

            concepts    = new List <ConceptUnit>();
            askConcept  = null;
            tmpConcepts = new List <ConceptUnit>();
            if (toutputEvent != null)
            {
                outputEvent = toutputEvent;
            }
            inputEvent = new sendChatMessageDelegate(input);

            baiduWordList = IOController.readBaiduWords("BaiduWord.txt");
        }