我已经制作了一个示例程序,用于在使用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)
但该程序没有打印任何内容..需要进行任何更改吗?
答案 0 :(得分:0)
如果有人需要,找到答案..记录器必须在
之前使用logging.basicConfig(format='%(message)s', level=logging.INFO)