本文整理汇总了Python中syntax_tree.Syntax_tree.get_node_to_node_path方法的典型用法代码示例。如果您正苦于以下问题:Python Syntax_tree.get_node_to_node_path方法的具体用法?Python Syntax_tree.get_node_to_node_path怎么用?Python Syntax_tree.get_node_to_node_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类syntax_tree.Syntax_tree
的用法示例。
在下文中一共展示了Syntax_tree.get_node_to_node_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_curr_first_prev_last_parse_path
# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_to_node_path [as 别名]
def get_curr_first_prev_last_parse_path(arg_clauses, clause_index, parse_dict):
DocID = arg_clauses.DocID
sent_index = arg_clauses.sent_index
if clause_index - 1 < 0:
return "NONE"
parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
syntax_tree = Syntax_tree(parse_tree)
curr_first_index = arg_clauses.clauses[clause_index][0][0]
prev_last_index = arg_clauses.clauses[clause_index - 1][0][-1]
curr_first_node = syntax_tree.get_leaf_node_by_token_index(curr_first_index)
prev_last_node = syntax_tree.get_leaf_node_by_token_index(prev_last_index)
return syntax_tree.get_node_to_node_path(curr_first_node, prev_last_node)
示例2: get_curr_first_to_prev_last_path
# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_to_node_path [as 别名]
def get_curr_first_to_prev_last_path(arg_clauses, clause_index, parse_dict):
if clause_index == 0:
return "NULL"
DocID = arg_clauses.DocID
sent_index = arg_clauses.sent_index
parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
syntax_tree = Syntax_tree(parse_tree)
if syntax_tree.tree == None:
return "NOTREE"
curr_first_index = arg_clauses.clauses[clause_index][0][0]
prev_last_index = arg_clauses.clauses[clause_index - 1][0][-1]
curr_first_node = syntax_tree.get_leaf_node_by_token_index(curr_first_index).up
prev_last_node = syntax_tree.get_leaf_node_by_token_index(prev_last_index).up
path = syntax_tree.get_node_to_node_path(curr_first_node, prev_last_node)
return path
示例3: get_curr_first_prev_last_parse_path
# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_to_node_path [as 别名]
def get_curr_first_prev_last_parse_path(arg_clauses, clause_index, parse_dict):
DocID = arg_clauses.DocID
sent_index = arg_clauses.sent_index
if clause_index - 1 < 0:
return "NONE"
parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
syntax_tree = Syntax_tree(parse_tree)
curr_first_index = arg_clauses.clauses[clause_index][0][0]
prev_last_index = arg_clauses.clauses[clause_index - 1][0][-1]
curr_first_node = syntax_tree.get_leaf_node_by_token_index(curr_first_index)
prev_last_node = syntax_tree.get_leaf_node_by_token_index(prev_last_index)
path = syntax_tree.get_node_to_node_path(curr_first_node, prev_last_node)
if path.find("<") != -1:
path_1 = path[:path.find("<")]
path_2 = path[path.find("<"):]
return util.get_compressed_path_tag(path_1, ">") + util.get_compressed_path_tag(path_2, "<")
else:
return util.get_compressed_path_tag(path, ">")