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


Python Syntax_tree.get_parent_category_node_by_token_indices方法代码示例

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


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

示例1: get_conn_parent_categoryCtx

# 需要导入模块: from syntax_tree import Syntax_tree [as 别名]
# 或者: from syntax_tree.Syntax_tree import get_parent_category_node_by_token_indices [as 别名]
def get_conn_parent_categoryCtx(parse_dict, DocID, sent_index, conn_indices):
    conn_name = get_conn_name(parse_dict, DocID, sent_index, conn_indices)

    parse_tree = parse_dict[DocID]["sentences"][sent_index]["parsetree"].strip()
    syntax_tree = Syntax_tree(parse_tree)
    if syntax_tree.tree == None:
        parent_categoryCtx = "NONE_TREE"
    else:
        parent_category_node = syntax_tree.get_parent_category_node_by_token_indices(conn_indices)
        parent_categoryCtx = get_node_linked_Ctx(parent_category_node)

    conn_parent_categoryCtx = "%s|%s" % (conn_name, parent_categoryCtx)

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

示例2: get_parent_category

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

    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:
            parent_category = parent_category_node.name

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

示例3: get_conn_parent_category_Ctx

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

    conn_name = get_con_str(arg_clauses, clause_index, parse_dict)

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

    if syntax_tree.tree == None:
        parent_categoryCtx = "NONE_TREE"
    else:
        parent_category_node = syntax_tree.get_parent_category_node_by_token_indices(conn_indices)
        parent_categoryCtx = get_node_linked_Ctx(parent_category_node, syntax_tree)

    conn_parent_categoryCtx = "%s|%s" % (conn_name, parent_categoryCtx)

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

示例4: all_features

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

#.........这里部分代码省略.........
        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:
            parent_category = parent_category_node.name

    if syntax_tree.tree == None:
        left_sibling_category = "NONE_TREE"
    else:
        left_sibling_category_node = syntax_tree.get_left_sibling_category_node_by_token_indices(conn_indices)
        if left_sibling_category_node == None:
            left_sibling_category = "NONE"
        else:
            left_sibling_category = left_sibling_category_node.name

    if syntax_tree.tree == None:
        right_sibling_category = "NONE_TREE"
    else:
        right_sibling_category_node = syntax_tree.get_right_sibling_category_node_by_token_indices(conn_indices)
        if right_sibling_category_node == None:
            right_sibling_category = "NONE"
        else:
            right_sibling_category = right_sibling_category_node.name


    prev_C = "%s|%s" % (prev, conn_name)
    prePOS_CPOS = "%s|%s" % (prevPOS, CPOS)
    C_next = "%s|%s" % (conn_name, next)
    CPOS_nextPOS = "%s|%s" % (CPOS, nextPOS)

    conn_self_category = "%s|%s" % (conn_name, self_category)
    conn_parent_category = "%s|%s" % (conn_name, parent_category)
    conn_left_sibling_category = "%s|%s" % (conn_name, left_sibling_category)
开发者ID:CoderChang,项目名称:conll2015_discourse,代码行数:70,代码来源:feature_functions.py


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