本文整理汇总了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")
示例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")
示例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, "*")
示例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")
示例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, "*")
示例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)