【发布时间】:2019-01-07 04:26:14
【问题描述】:
我有两个预训练的词嵌入:Glove.840b.300.txt 和 custom_glove.300.txt
一个是斯坦福预训练的,另一个是我训练的。 两者都有不同的词汇集。为了减少oov,我想将file1中没有出现但确实出现在file2中的单词添加到file1中。 我如何轻松做到这一点?
这就是我在 gensim 3.4.0 中加载和保存文件的方式。
from gensim.models.keyedvectors import KeyedVectors
model = KeyedVectors.load_word2vec_format('path/to/thefile')
model.save_word2vec_format('path/to/GoogleNews-vectors-negative300.txt', binary=False)
【问题讨论】: