Skip to content

Commit

Permalink
Fixing piskvorky#1198: LdaMallet show_topic should use topn parameter…
Browse files Browse the repository at this point in the history
… name to match other topic models
  • Loading branch information
Pranaydeep Singh committed Mar 18, 2017
1 parent 8b39e6e commit 048d204
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gensim/models/wrappers/ldamallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,18 @@ def show_topics(self, num_topics=10, num_words=10, log=False, formatted=True):
if formatted:
topic = self.print_topic(i, topn=num_words)
else:
topic = self.show_topic(i, num_words=num_words)
topic = self.show_topic(i, topn=num_words)
shown.append((i, topic))
if log:
logger.info("topic #%i (%.3f): %s", i, self.alpha[i], topic)
return shown

def show_topic(self, topicid, num_words=10):
def show_topic(self, topicid, topn=10):
if self.word_topics is None:
logger.warn("Run train or load_word_topics before showing topics.")
topic = self.word_topics[topicid]
topic = topic / topic.sum() # normalize to probability dist
bestn = matutils.argsort(topic, num_words, reverse=True)
bestn = matutils.argsort(topic, topn, reverse=True)
beststr = [(self.id2word[id], topic[id]) for id in bestn]
return beststr

Expand Down

0 comments on commit 048d204

Please sign in to comment.