当前位置: 首页>>代码示例>>Python>>正文


Python PatternGraph.add_that_to_node方法代码示例

本文整理汇总了Python中programy.parser.pattern.graph.PatternGraph.add_that_to_node方法的典型用法代码示例。如果您正苦于以下问题:Python PatternGraph.add_that_to_node方法的具体用法?Python PatternGraph.add_that_to_node怎么用?Python PatternGraph.add_that_to_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在programy.parser.pattern.graph.PatternGraph的用法示例。


在下文中一共展示了PatternGraph.add_that_to_node方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_add_that_to_node_pattern_with_set

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_that_to_node_pattern_with_set(self):
        graph = PatternGraph()

        base_node = PatternWordNode("THAT_TEST")

        that_element = ET.fromstring('<that>HELLO <set name="test" /> WORLD</that>')

        end_node = graph.add_that_to_node(that_element, base_node)
        self.assertIsNotNone(end_node)

        self.assertIsNotNone(base_node)
        self.assertIsNotNone(base_node.that)
        self.assertIsInstance(base_node.that, PatternThatNode)

        self.assertTrue(base_node.that.has_children())
        self.assertIsInstance(base_node.that.children[0], PatternWordNode)
        self.assertEqual(base_node.that.children[0].word, "HELLO")

        self.assertTrue(base_node.that.children[0].has_children())
        self.assertIsInstance(base_node.that.children[0].children[0], PatternSetNode)
        self.assertEqual(base_node.that.children[0].children[0].word, "TEST")

        self.assertTrue(base_node.that.children[0].children[0].has_children())
        self.assertIsInstance(base_node.that.children[0].children[0].children[0], PatternWordNode)
        self.assertEqual(base_node.that.children[0].children[0].children[0].word, "WORLD")
开发者ID:Doshmaku,项目名称:program-y,代码行数:27,代码来源:test_graph.py

示例2: test_add_that_to_node_word

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_that_to_node_word(self):
        graph = PatternGraph()
        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)
        self.assertIsNotNone(that_node)
        self.assertIsInstance(that_node, PatternOneOrMoreWildCardNode)
        self.assertEqual(that_node.wildcard, "*")
开发者ID:Doshmaku,项目名称:program-y,代码行数:24,代码来源:test_graph.py

示例3: test_add_that_to_node_word

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    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")
开发者ID:Freiza,项目名称:program-y,代码行数:24,代码来源:test_graph.py

示例4: test_add_template_to_node

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_template_to_node(self):
        graph = PatternGraph()
        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)
开发者ID:Doshmaku,项目名称:program-y,代码行数:26,代码来源:test_graph.py

示例5: test_add_topic_to_node_word

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_topic_to_node_word(self):
        graph = PatternGraph()
        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)
        self.assertIsNotNone(topic_node)
        self.assertIsInstance(topic_node, PatternWordNode)
        self.assertEqual(topic_node.word, "THERE")
开发者ID:Doshmaku,项目名称:program-y,代码行数:18,代码来源:test_graph.py

示例6: test_add_topic_to_node_wildcard

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    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, "*")
开发者ID:Freiza,项目名称:program-y,代码行数:18,代码来源:test_graph.py

示例7: test_add_that_to_node_star

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_that_to_node_star(self):
        graph = PatternGraph()

        base_node = PatternWordNode("THAT_TEST")

        that_element = ET.fromstring('<that>*</that>')

        end_node = graph.add_that_to_node(that_element, base_node)
        self.assertIsNotNone(end_node)

        self.assertIsNotNone(base_node)
        self.assertIsNotNone(base_node.that)
        self.assertIsInstance(base_node.that, PatternThatNode)

        self.assertFalse(base_node.that.has_children())
        self.assertTrue(base_node.that.has_wildcard())
        self.assertIsNotNone(base_node.that.star)
        self.assertEqual(base_node.that.star.wildcard, "*")
开发者ID:Doshmaku,项目名称:program-y,代码行数:20,代码来源:test_graph.py

示例8: test_add_that_to_node_pattern

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_that_to_node [as 别名]
    def test_add_that_to_node_pattern(self):
        graph = PatternGraph(self._client_context.brain.aiml_parser)

        base_node = PatternWordNode("THAT_TEST")

        that_element = ET.fromstring('<that>HELLO WORLD</that>')

        end_node = graph.add_that_to_node(that_element, base_node)
        self.assertIsNotNone(end_node)

        self.assertIsNotNone(base_node)
        self.assertIsNotNone(base_node.that)
        self.assertIsInstance(base_node.that, PatternThatNode)

        self.assertTrue(base_node.that.has_children())
        self.assertIsInstance(base_node.that.children[0], PatternWordNode)
        self.assertEqual(base_node.that.children[0].word, "HELLO")

        self.assertTrue(base_node.that.children[0].has_children())
        self.assertIsInstance(base_node.that.children[0].children[0], PatternWordNode)
        self.assertEqual(base_node.that.children[0].children[0].word, "WORLD")
开发者ID:Freiza,项目名称:program-y,代码行数:23,代码来源:test_graph.py


注:本文中的programy.parser.pattern.graph.PatternGraph.add_that_to_node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。