本文整理汇总了Python中programy.parser.pattern.graph.PatternGraph.count_words_in_patterns方法的典型用法代码示例。如果您正苦于以下问题:Python PatternGraph.count_words_in_patterns方法的具体用法?Python PatternGraph.count_words_in_patterns怎么用?Python PatternGraph.count_words_in_patterns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类programy.parser.pattern.graph.PatternGraph
的用法示例。
在下文中一共展示了PatternGraph.count_words_in_patterns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_count_word_in_patterns
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import count_words_in_patterns [as 别名]
def test_count_word_in_patterns(self):
graph = PatternGraph()
count = graph.count_words_in_patterns()
self.assertEquals(0, count)
graph = PatternGraph()
pattern = ET.fromstring("<pattern>HELLO</pattern>")
topic = ET.fromstring("<topic>HELLO</topic>")
that = ET.fromstring("<that>HELLO</that>")
template = TemplateWordNode("TEST")
graph.add_pattern_to_graph(pattern, topic, that, template)
count = graph.count_words_in_patterns()
self.assertEquals(1, count)
示例2: test_count_words_in_patterns
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import count_words_in_patterns [as 别名]
def test_count_words_in_patterns(self):
graph = PatternGraph(self._client_context.brain.aiml_parser)
count = graph.count_words_in_patterns()
self.assertEquals(0, count)
graph = PatternGraph(self._client_context.brain.aiml_parser)
pattern1 = ET.fromstring("<pattern>HELLO THErE</pattern>")
topic = ET.fromstring("<topic>HELLO</topic>")
that = ET.fromstring("<that>HELLO</that>")
template = TemplateWordNode("TEST")
graph.add_pattern_to_graph(pattern1, topic, that, template)
count = graph.count_words_in_patterns()
self.assertEquals(2, count)
pattern2 = ET.fromstring("<pattern>WHERE ARE YOU</pattern>")
graph.add_pattern_to_graph(pattern2, topic, that, template)
count = graph.count_words_in_patterns()
self.assertEquals(5, count)