Exemple #1
0
 def test_add_pattern_to_node(self):
     graph = PatternGraph(self._client_context.brain.aiml_parser)
     pattern = ET.fromstring('<pattern>HELLO</pattern>')
     node = graph.add_pattern_to_node(pattern)
     self.assertIsNotNone(node)
     self.assertIsInstance(node, PatternWordNode)
     self.assertEqual(node.word, "HELLO")
Exemple #2
0
    def test_add_topic_to_node_wildcard(self):
        graph = PatternGraph(self._client_context.brain.aiml_parser)
        pattern = ET.fromstring("""
        <pattern>
            HELLO
        </pattern>""")
        pattern_node = graph.add_pattern_to_node(pattern)

        topic = ET.fromstring("""
        <topic>
            *
        </topic>""")
        topic_node = graph.add_that_to_node(topic, pattern_node)
        self.assertIsNotNone(topic_node)
        self.assertIsInstance(topic_node, PatternOneOrMoreWildCardNode)
        self.assertEqual(topic_node.wildcard, "*")
Exemple #3
0
    def test_add_that_to_node_word(self):
        graph = PatternGraph(self._client_context.brain.aiml_parser)
        pattern = ET.fromstring("""
        <pattern>
            HELLO
        </pattern>""")
        pattern_node = graph.add_pattern_to_node(pattern)

        topic = ET.fromstring("""
        <topic>
            THERE
        </topic>""")
        topic_node = graph.add_that_to_node(topic, pattern_node)

        that = ET.fromstring("""
        <that>
            HERE
        </that>""")
        that_node = graph.add_that_to_node(that, topic_node)
        self.assertIsNotNone(that_node)
        self.assertIsInstance(that_node, PatternWordNode)
        self.assertEqual(that_node.word, "HERE")
Exemple #4
0
    def test_add_template_to_node(self):
        graph = PatternGraph(self._client_context.brain.aiml_parser)
        pattern = ET.fromstring("""
        <pattern>
            HELLO
        </pattern>""")
        pattern_node = graph.add_pattern_to_node(pattern)

        topic = ET.fromstring("""
        <topic>
            THERE
        </topic>""")
        topic_node = graph.add_that_to_node(topic, pattern_node)

        that = ET.fromstring("""
        <that>
            *
        </that>""")
        that_node = graph.add_that_to_node(that, topic_node)

        template = TemplateWordNode("TEST")
        template_node = graph.add_template_to_node(template, that_node)
        self.assertIsNotNone(template_node)
        self.assertIsInstance(template_node, PatternTemplateNode)