Exemple #1
0
        private bool isAnswerDeal(string str)
        {
            bool isa = false;

            if (askConcept == null)
            {
                return(isa);
            }


            string[] yeswords = { "改", "好", "行", "嗯", "ok", "OK", "哦" };
            string[] nowords  = { "不", "别", "no", "NO", "甭", "算了" };

            foreach (var w in nowords)
            {
                if (str.Contains(w))
                {
                    isa = true;
                    tmpOutputSentence.Add("哦,好吧。");
                    askConcept = null;
                    break;
                }
            }
            foreach (var w in yeswords)
            {
                if (str.Contains(w))
                {
                    isa = true;
                    tmpOutputSentence.Add("嗯,我记住了," + askConcept.toString());
                    var oldc = searchConcept(askConcept, true);
                    if (oldc != null)
                    {
                        int id = searchConcept(askConcept, true).id;
                        removeConceptById(id);
                    }
                    concepts.Add(new ConceptUnit(askConcept));
                    askConcept = null;
                    break;
                }
            }

            return(isa);
        }
Exemple #2
0
 private void LogicTellDeal(string str)
 {
     foreach (var w in tmpConcepts)
     {
         ConceptUnit cu = searchConcept(w, true);
         if (cu != null)
         {
             //tmpOutputSentence.Add("我记得:" + cu.toString() + "?");
             int not1 = 0;
             int not2 = 0;
             foreach (var predw in cu.apred)
             {
                 if (predw.word == "不")
                 {
                     not1++;
                 }
             }
             foreach (var predw in w.apred)
             {
                 if (predw.word == "不")
                 {
                     not2++;
                 }
             }
             if (not1 == not2)
             {
                 tmpOutputSentence.Add("嗯,是这样的。");
             }
             else
             {
                 tmpOutputSentence.Add("不,我记得" + cu.toString());
                 tmpOutputSentence.Add("唔,这件事是我记错了吗……要改了它?");
                 askConcept = new ConceptUnit(w);
             }
         }
         else
         {
             tmpOutputSentence.Add("好,我记住了," + w.toString());
             concepts.Add(w);
         }
     }
 }
Exemple #3
0
        private bool LogicAskDeal(string str)
        {
            bool lga = false;

            foreach (var w in tmpConcepts)
            {
                //tmpOutputSentence.Add("我记得:" + cu.toString() + "?");
                bool     isAskWhat = false;
                string[] whatWords = { "什么", "谁", "哪" };
                foreach (var word in whatWords)
                {
                    if (w.obj.word.Contains(word))
                    {
                        isAskWhat = true;
                        break;
                    }
                }
                if (isAskWhat)
                {
                    //是在询问一件事情
                    ConceptUnit cu = searchConcept(w);
                    if (cu != null)
                    {
                        lga = true;
                        tmpOutputSentence.Add("我记得" + cu.toString());
                    }
                    else
                    {
                        lga = false;
                    }
                }
                else
                {
                    //是在证实一件事情
                    ConceptUnit cu = searchConcept(w, true);
                    if (cu != null)
                    {
                        lga = true;
                        int not1 = 0;
                        int not2 = 0;
                        foreach (var predw in cu.apred)
                        {
                            if (predw.word == "不")
                            {
                                not1++;
                            }
                        }
                        foreach (var predw in w.apred)
                        {
                            if (predw.word == "不")
                            {
                                not2++;
                            }
                        }
                        if (not1 == not2)
                        {
                            tmpOutputSentence.Add("是的。");
                        }
                        else
                        {
                            tmpOutputSentence.Add("不,我记得" + cu.toString());
                        }
                    }
                    else
                    {
                        lga = false;
                    }
                }
            }

            return(lga);
        }