sgns2text.py 文件源码

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

项目:histwords 作者: williamleif 项目源码 文件源码
def main():
    args = docopt("""
    Usage:
        sgns2text.py [options] <sgns_path> <output_path>

    Options:
        --w+c        Use ensemble of word and context vectors
    """)

    sgns_path = args['<sgns_path>']
    output_path = args['<output_path>']
    w_c = args['--w+c']

    if w_c:
        sgns = EnsembleEmbedding(Embedding(sgns_path + '.words', False), Embedding(sgns_path + '.contexts', False), True)
    else:
        sgns = Embedding(sgns_path + '.words', True)

    with open(output_path, 'w') as f:
        for i, w in enumerate(sgns.iw):
            print >>f, w, ' '.join([str(x) for x in sgns.m[i]])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号