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


Python PatternGraph.count_words_in_patterns方法代码示例

本文整理汇总了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)
开发者ID:Doshmaku,项目名称:program-y,代码行数:15,代码来源:test_graph.py

示例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)
开发者ID:Freiza,项目名称:program-y,代码行数:20,代码来源:test_graph.py


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