當前位置: 首頁>>代碼示例>>Python>>正文


Python Syntax_tree.get_node_to_node_path方法代碼示例

本文整理匯總了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)
開發者ID:alishir,項目名稱:conll2015_discourse,代碼行數:19,代碼來源:ps_arg2_dict_util.py

示例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
開發者ID:CoderChang,項目名稱:conll2015_discourse,代碼行數:23,代碼來源:implicit_arg2_dict_util.py

示例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, ">")
開發者ID:CoderChang,項目名稱:conll2015_discourse,代碼行數:26,代碼來源:ps_arg1_dict_util.py


注:本文中的syntax_tree.Syntax_tree.get_node_to_node_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。