コード例 #1
1
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateTimeOut()
        {
            _chatBot = new ChatBot();
            ConfigurationManager.AppSettings["timeoutMax"] = "10";
            _node = new Node();
            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);

            var path = "Test 1 <that> that <topic> topic";
            var template = "<srai>TEST</srai>";

            _node = new Node();
            _node.AddCategory(path, template);

            var pathAlt = "Alt Test <that> that <topic> topic";
            var templateAlt = "<srai>TEST ALT</srai>";

            _node.AddCategory(pathAlt, templateAlt);
            _subQuery = new SubQuery(path);

            Thread.Sleep(20);

            var result =
                _node.Evaluate("Test 1 <that> that <topic> topic", _subQuery, _request, MatchState.UserInput,
                    new StringBuilder());
            Assert.AreEqual(string.Empty, result);
            Assert.AreEqual(true, _request.HasTimedOut);
        }
コード例 #2
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void testEvaluateWith_WildCardThat()
        {
            var path = "Test 1 <that> _ <topic> topic";
            var template = "<srai>TEST</srai>";
            _node = new Node();
            _node.AddCategory(path, template);

            var pathAlt = "Alt Test <that> that <topic> topic";
            var templateAlt = "<srai>TEST ALT</srai>";

            _node.AddCategory(pathAlt, templateAlt);
            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);
            var result = _node.Evaluate("Test 1 <that> WILDCARD WORDS <topic> topic", _subQuery, _request,
    MatchState.UserInput, new StringBuilder());

            Assert.AreEqual("<srai>TEST</srai>", result);
            Assert.AreEqual("WILDCARD WORDS", _subQuery.ThatStar[0]);
        }
コード例 #3
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateWithWildcardsInDifferentPartsOfPath()
        {
            var path = "Test * 1 <that> Test * 1 <topic> Test * 1";
            var template = "<srai>TEST</srai>";

            _node = new Node();
            _node.AddCategory(path, template);

            var pathAlt = "Alt Test <that> that <topic> topic";
            var templateAlt = "<srai>TEST ALT</srai>";

            _node.AddCategory(pathAlt, templateAlt);

            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);

            Assert.AreEqual("<srai>TEST</srai>",
                _node.Evaluate(
                    "Test WILDCARD USER WORDS 1 <that> Test WILDCARD THAT WORDS 1 <topic> Test WILDCARD TOPIC WORDS 1",
                    _subQuery, _request, MatchState.UserInput, new StringBuilder()));
            Assert.AreEqual("WILDCARD USER WORDS", _subQuery.InputStar[0]);
            Assert.AreEqual("WILDCARD THAT WORDS", _subQuery.ThatStar[0]);
            Assert.AreEqual("WILDCARD TOPIC WORDS", _subQuery.TopicStar[0]);
        }
コード例 #4
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateWithStarWildCardUserInputNotMatched()
        {
            var path = "Test * 1 <that> that <topic> topic>";
            var template = "<srai>TEST</srai>";
            _node = new Node();
            _node.AddCategory(path, template);

            var pathAlt = "Alt Test <that> that <topic> topic";
            var templateAlt = "<srai>TEST ALT</srai>";

            _node.AddCategory(pathAlt, templateAlt);
            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);
            Assert.AreEqual("<srai>TEST ALT</srai>",
                _node.Evaluate("Alt Test <that> that <topic> topic", _subQuery, _request,
                    MatchState.UserInput, new StringBuilder()));
        }
コード例 #5
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateWithMultipleWildcardsSwitched()
        {
            var path = "Test * 1 _ <that> Test * 1 _ <topic> Test _ 1 *";
            var template = "<srai>TEST</srai>";

            _node = new Node();
            _node.AddCategory(path, template);

            var pathAlt = "Alt Test <that> that <topic> topic";
            var templateAlt = "<srai>TEST ALT</srai>";

            _node.AddCategory(pathAlt, templateAlt);

            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);

            Assert.AreEqual("<srai>TEST</srai>",
                _node.Evaluate(
                    "Test FIRST USER 1 SECOND USER <that> Test FIRST THAT 1 SECOND THAT <topic> Test FIRST TOPIC 1 SECOND TOPIC",
                    _subQuery, _request, MatchState.UserInput, new StringBuilder()));
            Assert.AreEqual(2, _subQuery.InputStar.Count);
            Assert.AreEqual("SECOND USER", _subQuery.InputStar[0]);
            Assert.AreEqual("FIRST USER", _subQuery.InputStar[1]);
            Assert.AreEqual(2, _subQuery.ThatStar.Count);
            Assert.AreEqual("SECOND THAT", _subQuery.ThatStar[0]);
            Assert.AreEqual("FIRST THAT", _subQuery.ThatStar[1]);
            Assert.AreEqual(2, _subQuery.TopicStar.Count);
            Assert.AreEqual("SECOND TOPIC", _subQuery.TopicStar[0]);
            Assert.AreEqual("FIRST TOPIC", _subQuery.TopicStar[1]);
        }
コード例 #6
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateWithInternationalCharset()
        {
            var path = "中 文 <that> * <topic> *";
            var template = "中文 (Chinese)";

            _node = new Node();
            _node.AddCategory(path, template);

            var path2 = "日 本 語 <that> * <topic> *";
            var template2 = "日 本 語 (Japanese)";

            _node.AddCategory(path2, template2);

            var path3 = "Русский язык <that> * <topic> *";
            var template3 = "Русский язык (Russian)";

            _node.AddCategory(path3, template3);

            _request = new Request("中 文", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);
            Assert.AreEqual("中文 (Chinese)",
                _node.Evaluate("中 文 <that> * <topic> *", _subQuery, _request, MatchState.UserInput,
                    new StringBuilder()));

            _request = new Request("日 本 語", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);
            Assert.AreEqual("日 本 語 (Japanese)",
                _node.Evaluate("日 本 語 <that> * <topic> *", _subQuery, _request, MatchState.UserInput,
                    new StringBuilder()));

            _request = new Request("Русский язык", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery(path);
            Assert.AreEqual("Русский язык (Russian)",
                _node.Evaluate("Русский язык <that> * <topic> *", _subQuery, _request,
                    MatchState.UserInput, new StringBuilder()));
        }
コード例 #7
0
ファイル: NodeTests - Copy.cs プロジェクト: rlebowitz/ai
        public void TestEvaluateWithEmptyNode()
        {
            _chatBot = new ChatBot();
            _node = new Node();
            _request = new Request("Test 1", new User("1", _chatBot), _chatBot);
            _subQuery = new SubQuery("Test 1 <that> that <topic> topic");

            Assert.AreEqual(string.Empty,
                _node.Evaluate("Test 1 <that> that <topic> topic", _subQuery, _request,
                    MatchState.UserInput, new StringBuilder()));
        }