def setUp(self): self.parser = TemplateGraph(AIMLParser()) self.assertIsNotNone(self.parser) self.test_brain = None self.test_sentence = Sentence("test sentence") test_node = PatternOneOrMoreWildCardNode("*") self.test_sentence._matched_context = MatchContext(max_search_depth=100, max_search_timeout=-1) 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, '*')] test_config = ProgramyConfiguration(self.get_client_config(), brain_config=self.get_brain_config(), bot_config=self.get_bot_config()) self.test_bot = Bot(Brain(self.get_brain_config()), config=test_config.bot_configuration) self.test_clientid = "testid" conversation = self.test_bot.get_conversation(self.test_clientid) question = Question.create_from_sentence(self.test_sentence) conversation._questions.append(question)
def setUp(self): self.parser = TemplateGraph(AIMLParser()) self.assertIsNotNone(self.parser) self.test_brain = None self.test_sentence = Sentence("test sentence") test_node = PatternOneOrMoreWildCardNode("*") self.test_sentence._matched_context = MatchContext() 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, '*')] test_config = ClientConfiguration() self.test_bot = Bot(Brain(BrainConfiguration()), config=test_config.bot_configuration) self.test_clientid = "testid" conversation = self.test_bot.get_conversation(self.test_clientid) question = Question.create_from_sentence(self.test_sentence) conversation._questions.append(question)
def test_question_create_from_sentence(self): sentence = Sentence("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)
def setUp(self): self.parser = TemplateGraph() self.assertIsNotNone(self.parser) self.test_brain = None self.test_sentence = Sentence("test sentence") self.test_sentence._stars = ['one', 'two', 'three', 'four', 'five', 'six'] self.test_sentence._thatstars = ["*"] self.test_sentence._topicstars = ["*"] test_config = ClientConfiguration() self.test_bot = Bot(Brain(BrainConfiguration()), config=test_config.bot_configuration) self.test_clientid = "testid" conversation = self.test_bot.get_conversation(self.test_clientid) question = Question.create_from_sentence(self.test_sentence) conversation._questions.append(question)