balAPinc.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:UnsupervisedHypernymy 作者: vered1986 项目源码 文件源码
def get_contexts_rank(targets, cooc_mat, target_index):
    """
    A dictionary in which each key is a target word and the value is a sorted list of
    context columns in descending order
    :param targets: the words
    :return:
    """
    contexts_rank = {}

    for target in targets:
        index = target_index.get(target, -1)

        if index == -1:
            contexts_rank[target] = []

        row = cooc_mat[index, :]
        contexts_rank[target] = sort_by_value_get_col(scipy.sparse.coo_matrix(row.mat)) # tuples of (row, col, value)

    return contexts_rank
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号