当前位置: 首页>>代码示例>>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;未经允许,请勿转载。