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


Python PatternGraph.add_pattern_to_node方法代码示例

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


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

示例1: test_add_pattern_to_node

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

示例2: test_add_pattern_to_node_whitespaces

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

示例3: test_add_topic_to_node_wildcard

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

示例4: test_add_topic_to_node_word

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_pattern_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

示例5: test_add_that_to_node_word

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

示例6: test_add_template_to_node

# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import add_pattern_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


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