本文整理匯總了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, ">")