diff --git a/orangecontrib/text/widgets/owtopicmodeling.py b/orangecontrib/text/widgets/owtopicmodeling.py index 5e2348695..4ee38cb78 100644 --- a/orangecontrib/text/widgets/owtopicmodeling.py +++ b/orangecontrib/text/widgets/owtopicmodeling.py @@ -267,6 +267,8 @@ def on_done(self, corpus): if self.model.name == "Latent Dirichlet Allocation": bound = self.model.model.log_perplexity(infer_ngrams_corpus(corpus)) self.perplexity = "{:.5f}".format(np.exp2(-bound)) + else: + self.perplexity = "n/a" # for small corpora it is slower to use more processes # there is no good estimation when multiprocessing is helpful, but it is # definitely not helpful for corpora smaller than 100 diff --git a/orangecontrib/text/widgets/tests/test_owtopicmodeling.py b/orangecontrib/text/widgets/tests/test_owtopicmodeling.py index 4424a18db..582d5dcad 100644 --- a/orangecontrib/text/widgets/tests/test_owtopicmodeling.py +++ b/orangecontrib/text/widgets/tests/test_owtopicmodeling.py @@ -22,7 +22,6 @@ def test_data(self): self.assertIsNone(output) def test_saved_selection(self): - self.widget.method_index = 1 self.send_signal(self.widget.Inputs.corpus, self.corpus) self.wait_until_finished() @@ -58,17 +57,16 @@ def test_topic_evaluation(self): self.send_signal(self.widget.Inputs.corpus, self.corpus) self.wait_until_finished() - # test LSI - self.assertEqual(self.widget.perplexity, "n/a") - self.assertNotEqual(self.widget.coherence, "n/a") - # test LDA, which is the only one with log perplexity + self.assertNotEqual(self.widget.perplexity, "n/a") + self.assertTrue(self.widget.coherence) + + # test LSI self.widget.method_index = 1 self.widget.commit.now() self.wait_until_finished() - - self.assertNotEqual(self.widget.perplexity, "n/a") - self.assertTrue(self.widget.coherence) + self.assertEqual(self.widget.perplexity, "n/a") + self.assertNotEqual(self.widget.coherence, "n/a") def test_migrate_settings_transform(self): # 0 used to be LSI in version <2 - it is on index 1 now