使用python gensim转换glove到word2vec
项目想直接用已经embed好的词向量,奈何要用word2vec格式。
这里有个可以下载的glove格式词向量。glove词向量传送门
里面这个名词的文件就是词向量文件
如何转成word2vec
文件太大,所以尽管用了这个还是需要一段时间,我i7 7700HQ 16G用了2分钟左右。
import gensim
from gensim.test.utils import datapath,get_tmpfile
from gensim.scripts.glove2word2vec import glove2word2vec
def transfer():
gloveFile=datapath('your glove file path')
word2vecFile=get_tmpfile('your word2vec file path')
glove2word2vec(gloveFile,word2vecFile)