예제 #1
0
        public Result HeardSelfSayResponse(bool saveResultsAsIfRealtime, bool useConversationDataAsIfRealtime, User theFactSpeaker, User toWhom, string message, Result resultOfToWhomSpeakingToFactSpeaker, ThreadControl control)
        {
            if (this.TurnOffSelfListening)
            {
                return(null);
            }
            Result LR = null;

            if (message == null)
            {
                return(null);
            }
            bool lts    = ListeningToSelf;
            bool prochp = ProcessHeardPreds;

            if (!lts && !prochp)
            {
                return(null);
            }
            message = ToHeard(message);
            if (string.IsNullOrEmpty(message))
            {
                return(null);
            }

            Result result = null;
            var    v      = new SplitIntoSentences(null, message);

            bool stopProcessing = false;

            if (control != null)
            {
                control.AbortOrInteruptedRaised += (ctl, ex) => { stopProcessing = true; }
            }
            ;
            var sentences = v.TransformU();

            for (int i = 0; i < sentences.Length; i++)
            {
                Unifiable sentence = sentences[i];
                if (stopProcessing)
                {
                    Unifiable unifiableJoin = Unifiable.Join(" <br> ", sentences, i, sentences.Length - 1);
                    return(AbortedResult(unifiableJoin, result, control));
                }
                result = HeardSomeoneSay1Sentence(saveResultsAsIfRealtime, useConversationDataAsIfRealtime, theFactSpeaker, toWhom, sentence, result, control);
            }
            return(result);
        }
예제 #2
0
 public void testSplitterAllMadeFromWhiteSpace()
 {
     this.mockSplitter = new SplitIntoSentences(this.mockBot, "     ");
     Assert.AreEqual(new string[0], this.mockSplitter.Transform());
 }
예제 #3
0
 public void testSplitterAllSentenceMadeOfSplitters()
 {
     this.mockSplitter = new SplitIntoSentences(this.mockBot, "!?.;");
     Assert.AreEqual(new string[0], this.mockSplitter.Transform());
 }
예제 #4
0
 public void testSplitterAllSentenceWithSplitterAtStart()
 {
     this.mockSplitter = new SplitIntoSentences(this.mockBot, ".This is a sentence without splitters");
     Assert.AreEqual("This is a sentence without splitters", (string)this.mockSplitter.Transform()[0]);
 }
예제 #5
0
 public void testSplitterAllNoRawInput()
 {
     this.mockSplitter = new SplitIntoSentences(this.mockBot, "");
     Assert.AreEqual(new string[0], this.mockSplitter.Transform());
 }
예제 #6
0
 public void testSplitterAllTokensPassedByMethod()
 {
     this.mockSplitter = new SplitIntoSentences(this.mockBot);
     Assert.AreEqual(this.goodResult, this.mockSplitter.Transform(rawInput));
 }
예제 #7
0
        // Token: 0x0600008E RID: 142 RVA: 0x000058A4 File Offset: 0x000048A4
        public Result Chat(Request request)
        {
            Result result = new Result(request.user, this, request);

            if (this.isAcceptingUserInput)
            {
                AIMLLoader         aimlloader         = new AIMLLoader(this);
                SplitIntoSentences splitIntoSentences = new SplitIntoSentences(this);
                string[]           array = splitIntoSentences.Transform(request.rawInput);
                foreach (string text in array)
                {
                    result.InputSentences.Add(text);
                    string item = aimlloader.generatePath(text, request.user.getLastBotOutput(), request.user.Topic, true);
                    result.NormalizedPaths.Add(item);
                }
                foreach (string text2 in result.NormalizedPaths)
                {
                    SubQuery subQuery = new SubQuery(text2);
                    subQuery.Template = this.Graphmaster.evaluate(text2, subQuery, request, MatchState.UserInput, new StringBuilder());
                    result.SubQueries.Add(subQuery);
                }
                using (List <SubQuery> .Enumerator enumerator2 = result.SubQueries.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        SubQuery subQuery2 = enumerator2.Current;
                        if (subQuery2.Template.Length > 0)
                        {
                            try
                            {
                                XmlNode node  = AIMLTagHandler.getNode(subQuery2.Template);
                                string  text3 = this.processNode(node, subQuery2, request, result, request.user);
                                if (text3.Length > 0)
                                {
                                    result.OutputSentences.Add(text3);
                                }
                            }
                            catch (Exception ex)
                            {
                                if (this.WillCallHome)
                                {
                                    this.phoneHome(ex.Message, request);
                                }
                                this.writeToLog(string.Concat(new string[]
                                {
                                    "WARNING! A problem was encountered when trying to process the input: ",
                                    request.rawInput,
                                    " with the template: \"",
                                    subQuery2.Template,
                                    "\""
                                }));
                            }
                        }
                    }
                    goto IL_1E4;
                }
            }
            result.OutputSentences.Add(this.NotAcceptingUserInputMessage);
IL_1E4:
            result.Duration = DateTime.Now - request.StartedOn;
            request.user.addResult(result);
            return(result);
        }