コード例 #1
0
ファイル: graph_test_client.py プロジェクト: zippyy/program-y
    def setUp(self):

        self._client = TemplateGraphClient()
        self._client_context = self._client.create_client_context("testid")

        self._graph = self._client_context.bot.brain.aiml_parser.template_parser

        self.test_sentence = Sentence(self._client_context.brain.tokenizer,
                                      "test sentence")

        test_node = PatternOneOrMoreWildCardNode("*")

        self.test_sentence._matched_context = MatchContext(
            max_search_depth=100,
            max_search_timeout=-1,
            tokenizer=self._client_context.brain.tokenizer)
        self.test_sentence._matched_context._matched_nodes = [
            Match(Match.WORD, test_node, 'one'),
            Match(Match.WORD, test_node, 'two'),
            Match(Match.WORD, test_node, 'three'),
            Match(Match.WORD, test_node, 'four'),
            Match(Match.WORD, test_node, 'five'),
            Match(Match.WORD, test_node, 'six'),
            Match(Match.TOPIC, test_node, '*'),
            Match(Match.THAT, test_node, '*')
        ]

        conversation = self._client_context.bot.get_conversation(
            self._client_context)
        question = Question.create_from_sentence(self.test_sentence)
        conversation._questions.append(question)
コード例 #2
0
ファイル: test_dialog.py プロジェクト: Freiza/program-y
 def test_question_create_from_sentence(self):
     sentence = Sentence(self._bot.brain.tokenizer, "One Two Three")
     question = Question.create_from_sentence(sentence)
     self.assertIsNotNone(question)
     self.assertEqual(1, len(question.sentences))
     self.assertEqual(sentence.text(), question.sentence(0).text())
     with self.assertRaises(Exception):
         question.sentence(1)
コード例 #3
0
ファイル: test_dialog.py プロジェクト: frdino131/RyanCBT
 def test_question_create_from_sentence(self):
     sentence = Sentence(self._bot.brain.tokenizer, "One Two Three")
     question = Question.create_from_sentence(sentence)
     self.assertIsNotNone(question)
     self.assertEqual(1, len(question.sentences))
     self.assertEqual(sentence.text(), question.sentence(0).text())
     with self.assertRaises(Exception):
         question.sentence(1)
コード例 #4
0
ファイル: test_transcript.py プロジェクト: Freiza/program-y
    def test_transcripts_questions_with_props(self):
        client = TranscriptAdminExtensionClient()
        client_context = client.create_client_context("testid")

        question = Question.create_from_sentence(Sentence(client_context.brain.tokenizer, "Hello World"))
        conversation = client_context.bot.get_conversation(client_context)
        conversation.record_dialog(question)

        extension = TranscriptAdminExtension()
        self.assertIsNotNone(extension)

        result = extension.execute(client_context, "PROPERTIES")
        self.assertIsNotNone(result)
        self.assertEquals("Questions:<br /><ul><li>Hello World - </li></ul><br />Properties:<br /><ul><li>topic = *</li></ul><br />", result)
コード例 #5
0
    def test_transcripts_questions_without_props(self):
        client = TranscriptAdminExtensionClient()
        client_context = client.create_client_context("testid")

        question = Question.create_from_sentence(
            Sentence(client_context.brain.tokenizer, "Hello World"))
        conversation = client_context.bot.get_conversation(client_context)
        conversation.record_dialog(question)

        extension = TranscriptAdminExtension()
        self.assertIsNotNone(extension)

        result = extension.execute(client_context, "")
        self.assertIsNotNone(result)
        self.assertEquals(
            "Questions:<br /><ul><li>Hello World - </li></ul><br />", result)