用gensim打印LDA后的主题分布

2024-03-28 14:54:52 发布

您现在位置:Python中文网/ 问答频道 /正文

在使用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)

但是程序没有打印任何东西。。是否需要更改?在


Tags: textin程序fordictionaryiscorpusdocument