【发布时间】:2020-03-08 11:40:00
【问题描述】:
【问题讨论】:
标签: python nlp gensim lda topic-modeling
【问题讨论】:
标签: python nlp gensim lda topic-modeling
Gensim 使用字典创建构成语料库的词袋模型。
# Make the dictionary from your texts
common_dictionary = Dictionary(common_texts)
# Use the dictionary to generate the corpus (set of bag-of-words models)
common_corpus = [common_dictionary.doc2bow(text) for text in common_texts]
然后您可以再次使用该词典从看不见的文本中生成一个新的但相似的语料库。
other_corpus = [common_dictionary.doc2bow(text) for text in other_texts]
您需要字典才能拥有语料库,因为语料库是由转换为词袋的文档组成的,并且构建词袋需要字典。词袋模型的其他实现(例如 sklearn 的 CountVectoriser)对您隐藏了字典,但它仍然存在。
【讨论】: