使用gensim在LDA之后打印主题分布
Printing topic distribution after LDA using gensim
我制作了一个示例程序,用于在使用 gensim 进行 LDA 后获取每个文档的主题分布
documents = ["Apple is releasing a new product",
"Amazon sells many things",
"Microsoft announces Nokia acquisition"]
stoplist=["is","are","am","were","a","me","I"]
texts = [[word for word in document.lower().split() if word not in stoplist] for document in documents]
dictionary = gensim.corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]
lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=2, update_every=1, chunksize=10000, passes=1)
lda.print_topics(2)
但是程序没有打印任何东西。需要进行任何更改吗?
如果有人需要,找到答案.. 必须在
之前使用记录器
logging.basicConfig(format='%(message)s', level=logging.INFO)
我制作了一个示例程序,用于在使用 gensim 进行 LDA 后获取每个文档的主题分布
documents = ["Apple is releasing a new product",
"Amazon sells many things",
"Microsoft announces Nokia acquisition"]
stoplist=["is","are","am","were","a","me","I"]
texts = [[word for word in document.lower().split() if word not in stoplist] for document in documents]
dictionary = gensim.corpora.Dictionary(texts)
corpus = [dictionary.doc2bow(text) for text in texts]
lda = gensim.models.ldamodel.LdaModel(corpus=corpus, id2word=dictionary, num_topics=2, update_every=1, chunksize=10000, passes=1)
lda.print_topics(2)
但是程序没有打印任何东西。需要进行任何更改吗?
如果有人需要,找到答案.. 必须在
之前使用记录器logging.basicConfig(format='%(message)s', level=logging.INFO)