本文整理汇总了Python中programy.parser.pattern.graph.PatternGraph.dump方法的典型用法代码示例。如果您正苦于以下问题:Python PatternGraph.dump方法的具体用法?Python PatternGraph.dump怎么用?Python PatternGraph.dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类programy.parser.pattern.graph.PatternGraph
的用法示例。
在下文中一共展示了PatternGraph.dump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PatternMatcherBaseClass
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import dump [as 别名]
class PatternMatcherBaseClass(PatternTestBaseClass):
@classmethod
def setUpClass(cls):
logging.getLogger().setLevel(logging.DEBUG)
PatternMatcherBaseClass.bot = TestBot()
PatternMatcherBaseClass.clientid = "matcher_test"
def setUp(self):
self._dump_graph = True
self.graph = PatternGraph()
self.matcher = AIMLParser()
def dump_graph(self):
if self._dump_graph is True:
self.graph.dump()
def add_pattern_to_graph(self, pattern, topic="*", that="*", template="test"):
pattern_element = ET.fromstring("<pattern>%s</pattern>"%(pattern))
topic_element = ET.fromstring("<topic>%s</topic>"%(topic))
that_element = ET.fromstring("<that>%s</that>"%(that))
template_node = TemplateWordNode(template)
self.matcher.pattern_parser.add_pattern_to_graph(pattern_element, topic_element, that_element, template_node)
def match_sentence(self, sentence, topic="*", that="*"):
return self.matcher.match_sentence( PatternMatcherBaseClass.bot,
PatternMatcherBaseClass.clientid,
Sentence(sentence),
topic,
that)