如何在使用 Gensim 包时从 LDA 的输出中删除数字和符号?

how to remove numbers and symbols from output of LDA while using Gensim package?

如何在使用 Gensim 包时从 LDA 的输出中删除这些数字?

2015-08-25 15:26:20,439 : INFO : topic #8 (0.100): 0.038*watch + 0.020*water + 0.014*strap + 0.011*analog + 0.011*resistance + 0.010*atm + 0.010*彩色 + 0.010*钟表 + 0.010*5 + 0.009*优雅

因此输出将是手表、水、表带...等

你可以使用 show_topic 其中 returns 一个元组列表(概率,单词)然后使用例如打印单词:

topic_tuple = lda.show_topic(0, 10)

print ','.join([str(word_tuple[1]) for word_tuple in topic_tuple])

基于gensim source code