Hi,
Thanks for reporting! Yes, it's known and is fixed. Merge mistake :)
Sorry you ran into this problem. A temp fix might be to import numpy as np in your script.
Chris.
--
You received this message because you are subscribed to the Google Groups "gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> To unsubscribe from this group and stop receiving emails from it, send an email to gensim+unsubscribe@googlegroups.com.
import itertools
gensim.models.ldamodel.ifilter = itertools.ifilter
2015-06-01 22:42:22,530 : INFO : loading LsiModel object from /home/knok/text/topic/lda/chatter.lsi.projection
Traceback (most recent call last):
File "./lda.py", line 61, in <module>
topics = lda.top_topics([vec])
File "/usr/local/lib/python2.7/dist-packages/gensim-0.11.1_1-py2.7-linux-x86_64.egg/gensim/models/ldamodel.py", line 779, in top_topics
doc_frequency_m = len(doc_word_list[word_m])
KeyError: 847
--- ldamodel.py.old 2015-06-01 22:40:03.484170877 +0900
+++ ldamodel.py 2015-06-01 22:42:06.016170862 +0900
@@ -776,9 +776,14 @@
for topic in xrange(len(topics)):
topic_coherence_sum = 0.0
for word_m in topics[topic][1:]:
- doc_frequency_m = len(doc_word_list[word_m])
- m_set = set(doc_word_list[word_m])
+ x = doc_word_list.get(word_m, None)
+ if x is None:
+ continue
+ doc_frequency_m = len(x)
+ m_set = set(x)
for word_l in topics[topic][:-1]:
+ if doc_word_list.get(word_l, None) is None:
+ continue
l_set = set(doc_word_list[word_l])
co_doc_frequency = len(m_set.intersection(l_set))
topic_coherence_sum += numpy.log(