gensim
Dictionary对象跟踪文档集合(即语料库)的词汇表。但是为了将数据馈送到对象中,必须将数据馈送到存储器中,例如
import io
from gensim.corpora import Dictionary
infile = '/path/to/data'
with io.open(infile, 'r', encoding='utf8') as fin:
d = Dictionary(map(lambda x: x.split(), fin.readlines()))
d.save('data.dict')
我可以将文件对象读入gensim Dictionary类吗?