当前位置: 首页>>代码示例>>Python>>正文


Python Syntax_tree.get_node_path_to_root方法代码示例

本文整理汇总了Python中syntax_tree.Syntax_tree.get_node_path_to_root方法的典型用法代码示例。如果您正苦于以下问题:Python Syntax_tree.get_node_path_to_root方法的具体用法?Python Syntax_tree.get_node_path_to_root怎么用?Python Syntax_tree.get_node_path_to_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在syntax_tree.Syntax_tree的用法示例。


在下文中一共展示了Syntax_tree.get_node_path_to_root方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_CParent_to_root_path_node_names

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_CParent_to_root_path_node_names(parse_dict,docID,sentID,conn_indices):
    parse_tree = parse_dict[docID]["sentences"][sentID]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)

    if syntax_tree.tree == None:
        path = "NONE_TREE"
    else:
        path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up
            path += syntax_tree.get_node_path_to_root(conn_parent_node) + "-->"
        if path[-3:] == "-->":
            path = path[:-3]
    return path.split("-->")
开发者ID:peeceeprashant,项目名称:SharedTask,代码行数:17,代码来源:func.py

示例2: get_conn_to_root_path

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_conn_to_root_path(parse_dict,docID,sentID,conn_indices):
    parse_tree = parse_dict[docID]["sentences"][sentID]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)
    if syntax_tree.tree == None:
        path = "NONE_TREE"
    else:
        path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            t = syntax_tree.get_node_path_to_root(conn_node)
            path += t + "&"
        if path[-1] == "&":
            path = path[:-1]

    return path
开发者ID:peeceeprashant,项目名称:SharedTask,代码行数:17,代码来源:func.py

示例3: get_CParent_to_root_path

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_CParent_to_root_path(parse_dict, DocID, sent_index, conn_indices):
    parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)

    ''' c parent to root '''
    if syntax_tree.tree == None:
        cparent_to_root_path = "NONE_TREE"
    else:
        cparent_to_root_path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up
            cparent_to_root_path += syntax_tree.get_node_path_to_root(conn_parent_node) + "&"
        if cparent_to_root_path[-1] == "&":
            cparent_to_root_path = cparent_to_root_path[:-1]

    return cparent_to_root_path
开发者ID:StevenLOL,项目名称:conll2015_discourse,代码行数:19,代码来源:NT_dict_util.py

示例4: get_conn_to_root_compressed_path

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_conn_to_root_compressed_path(parse_dict,docID,sentID,conn_indices):
    parse_tree = parse_dict[docID]["sentences"][sentID]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)
    if syntax_tree.tree == None:
        compressed_path = "NONE_TREE"
    else:
        compressed_path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
	    conn_parent_node = conn_node.up
	    path = syntax_tree.get_node_path_to_root(conn_parent_node)
	    compressed_path += util.get_compressed_path(path) + "&"
            #t = syntax_tree.get_node_path_to_root(conn_node)
            #path += t + "&"
        if compressed_path[-1] == "&":
            compressed_path = compressed_path[:-1]
    return compressed_path
开发者ID:peeceeprashant,项目名称:SharedTask,代码行数:19,代码来源:func.py

示例5: get_conn_to_root_path

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_conn_to_root_path(arg_clauses, clause_index, parse_dict):
    conn_indices = arg_clauses.conn_indices
    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:
        path = "NONE_TREE"
    else:
        path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            t = syntax_tree.get_node_path_to_root(conn_node)
            path += t + "&"
        if path[-1] == "&":
            path = path[:-1]

    return path
开发者ID:alishir,项目名称:conll2015_discourse,代码行数:20,代码来源:ps_arg2_dict_util.py

示例6: get_CParent_to_root_path_node_names

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_CParent_to_root_path_node_names(arg_clauses, clause_index, parse_dict):
    DocID = arg_clauses.DocID
    sent_index = arg_clauses.sent_index
    conn_indices = arg_clauses.conn_indices

    parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)

    if syntax_tree.tree == None:
        path = "NONE_TREE"
    else:
        path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up
            path += syntax_tree.get_node_path_to_root(conn_parent_node) + "-->"
        if path[-3:] == "-->":
            path = path[:-3]

    return path.split("-->")
开发者ID:alishir,项目名称:conll2015_discourse,代码行数:22,代码来源:ps_arg2_dict_util.py

示例7: get_conn_to_root_compressed_path

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]
def get_conn_to_root_compressed_path(arg_clauses, clause_index, parse_dict):
    DocID = arg_clauses.DocID
    sent_index = arg_clauses.sent_index
    conn_indices = arg_clauses.conn_indices
    parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)

    if syntax_tree.tree == None:
        compressed_path = "NONE_TREE"
    else:
        compressed_path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up

            path = syntax_tree.get_node_path_to_root(conn_parent_node)

            compressed_path += util.get_compressed_path(path) + "&"

        if compressed_path[-1] == "&":
            compressed_path = compressed_path[:-1]
    return compressed_path
开发者ID:alishir,项目名称:conll2015_discourse,代码行数:24,代码来源:ps_arg2_dict_util.py

示例8: all_features

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_node_path_to_root [as 别名]

#.........这里部分代码省略.........
    flag = 0
    next_index = conn_indices[-1] + 1
    next_sent_index = sent_index
    if next_index >= sent_length:
        next_sent_index += 1
        next_index = 0
        if next_sent_index >= sent_count:
            flag = 1

    if flag == 1:
        next = "NONE"
    else:
        next = parse_dict[DocID]["sentences"][next_sent_index]["words"][next_index][0]

    ''' next pos '''
    if next == "NONE":
        nextPOS = "NONE"
    else:
        nextPOS = parse_dict[DocID]["sentences"][next_sent_index]["words"][next_index][1]["PartOfSpeech"]


    parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)


    ''' c parent to root '''
    if syntax_tree.tree == None:
        cparent_to_root_path = "NONE_TREE"
    else:
        cparent_to_root_path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up
            cparent_to_root_path += syntax_tree.get_node_path_to_root(conn_parent_node) + "&"
        if cparent_to_root_path[-1] == "&":
            cparent_to_root_path = cparent_to_root_path[:-1]

    ''' compressed c parent to root '''
    if syntax_tree.tree == None:
        compressed_path = "NONE_TREE"
    else:
        compressed_path = ""
        for conn_index in conn_indices:
            conn_node = syntax_tree.get_leaf_node_by_token_index(conn_index)
            conn_parent_node = conn_node.up

            path = syntax_tree.get_node_path_to_root(conn_parent_node)

            compressed_path += util.get_compressed_path(path) + "&"

        if compressed_path[-1] == "&":
            compressed_path = compressed_path[:-1]

    ''' Pitler '''
    if syntax_tree.tree == None:
        self_category = "NONE_TREE"
    else:
        self_category = syntax_tree.get_self_category_node_by_token_indices(conn_indices).name

    if syntax_tree.tree == None:
        parent_category = "NONE_TREE"
    else:
        parent_category_node = syntax_tree.get_parent_category_node_by_token_indices(conn_indices)
        if parent_category_node == None:
            parent_category = "ROOT"
        else:
开发者ID:CoderChang,项目名称:conll2015_discourse,代码行数:70,代码来源:feature_functions.py


注:本文中的syntax_tree.Syntax_tree.get_node_path_to_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。