本文整理汇总了Python中programy.parser.pattern.graph.PatternGraph._parse_text方法的典型用法代码示例。如果您正苦于以下问题:Python PatternGraph._parse_text方法的具体用法?Python PatternGraph._parse_text怎么用?Python PatternGraph._parse_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类programy.parser.pattern.graph.PatternGraph
的用法示例。
在下文中一共展示了PatternGraph._parse_text方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_text_oneormore
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_oneormore(self):
graph = PatternGraph()
root = PatternRootNode()
final_node = graph._parse_text("_", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternOneOrMoreWildCardNode)
final_node = graph._parse_text("*", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternOneOrMoreWildCardNode)
示例2: test_parse_text_zeroormore
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_zeroormore(self):
graph = PatternGraph(self._client_context.brain.aiml_parser)
root = PatternRootNode()
final_node = graph._parse_text("^", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternZeroOrMoreWildCardNode)
final_node = graph._parse_text("#", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternZeroOrMoreWildCardNode)
示例3: test_parse_text_multiple_words
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_multiple_words(self):
graph = PatternGraph()
root = PatternRootNode()
final_node = graph._parse_text("HELLO THERE", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternWordNode)
self.assertEqual(final_node.word, "THERE")
示例4: test_parse_text_nothing
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_nothing(self):
graph = PatternGraph()
root = PatternRootNode()
final_node = graph._parse_text("", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternRootNode)
self.assertEqual(final_node, root)
示例5: test_parse_text_multiple_words_whitespaces
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_multiple_words_whitespaces(self):
graph = PatternGraph(self._client_context.brain.aiml_parser)
root = PatternRootNode()
final_node = graph._parse_text("HELLO \t\n\r THERE", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternWordNode)
self.assertEqual(final_node.word, "THERE")
示例6: test_parse_text_word
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_word(self):
graph = PatternGraph(self._client_context.brain.aiml_parser)
root = PatternRootNode()
final_node = graph._parse_text("HELLO", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternWordNode)
self.assertEqual(final_node.word, "HELLO")
示例7: test_parse_text_priority
# 需要导入模块: from programy.parser.pattern.graph import PatternGraph [as 别名]
# 或者: from programy.parser.pattern.graph.PatternGraph import _parse_text [as 别名]
def test_parse_text_priority(self):
graph = PatternGraph()
root = PatternRootNode()
final_node = graph._parse_text("$HELLO", root)
self.assertIsNotNone(final_node)
self.assertIsInstance(final_node, PatternPriorityWordNode)