I am doing some topic modeling on newspaper articles, and have implemented LDA using gensim in Python3. Now I want to create a word cloud for each topic, using the top 20 words for each topic. I know I can print the words, and save the LDA model, but is there any way to just save the top words for each topic which I can further use for generating word clouds?
I tried to google it, but could not find anything relevant. Any help is appreciated.
You may also consider using pyldavis package which can be used to visualize LDA models generated through gensim. An example is shown here
You can get the topn words from an LDA model using Gensim's built-in method show_topic.
This will write a file with a format similar to this:
You may or may not need to adjust this to your needs, ie yield a list of top 20 words instead of outputting it to a text file.
The answer in this post gives a good explanation of how to use raw text to create the word clouds. How do I print lda topic model and the word cloud of each of the topics
is there any way to just save the top words for each topic ?
Yes there is. jLDADMM outputs the top topical words for each topic. In version 1.0, only top topical words are written in the top-word output file, without their probabilities given the topic.