cooccurgen.py 文件源码

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

项目:histwords 作者: williamleif 项目源码 文件源码
def run(word_gen, index, window_size, out_file):
    context = []
    pair_counts = Counter()
    for word in word_gen:
        context.append(index[word])
        if len(context) > window_size * 2 + 1:
            context.pop(0)
        pair_counts = _process_context(context, pair_counts, window_size)
    import pyximport
    pyximport.install(setup_args={"include_dirs": np.get_include()})
    from representations import sparse_io
    sparse_io.export_mat_from_dict(pair_counts, out_file)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号