Skip to content

Commit

Permalink
Merge pull request #17 from log0ymxm/patch-1
Browse files Browse the repository at this point in the history
Fix assumption that gensim dictionary and corpus are built from same …
  • Loading branch information
bmabey committed Jul 24, 2015
2 parents 6e7144b + 698e1c9 commit 69719cd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyLDAvis/gensim.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ def _extract_data(topic_model, corpus, dictionary):
doc_lengths = [sum([t[1] for t in doc]) for doc in corpus]

term_freqs_dict = fp.merge_with(sum, *corpus)
N = len(term_freqs_dict)

vocab = [dictionary[id] for id in xrange(N)]
term_freqs = [term_freqs_dict[id] for id in xrange(N)]
vocab = [dictionary[id] for id in term_freqs_dict.keys()]
term_freqs = term_freqs_dict.values()

gamma, _ = topic_model.inference(corpus)
doc_topic_dists = _normalize(gamma)
Expand Down

0 comments on commit 69719cd

Please sign in to comment.