Skip to content

Commit

Permalink
Word Cloud: test document count output
Browse files Browse the repository at this point in the history
  • Loading branch information
ajdapretnar committed Mar 22, 2024
1 parent e75d751 commit 43f24cd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions orangecontrib/text/widgets/tests/test_owwordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def test_bow_features(self):
np.testing.assert_array_almost_equal(weights, [1, 2, 2])

output = self.get_output(self.widget.Outputs.word_counts)
np.testing.assert_array_almost_equal([2, 2, 1], output.X.flatten())
np.testing.assert_array_almost_equal([2, 2, 1], output.X[:,
0].flatten())
np.testing.assert_array_equal(
["Word3", "Word2", "Word1"], output.metas.flatten())
self.assertTupleEqual(
Expand All @@ -93,7 +94,7 @@ def test_bow_features(self):
np.testing.assert_array_almost_equal(weights, [1, 2])

output = self.get_output(self.widget.Outputs.word_counts)
np.testing.assert_array_almost_equal([2, 1], output.X.flatten())
np.testing.assert_array_almost_equal([2, 1], output.X[:, 0].flatten())
np.testing.assert_array_equal(
["Word2", "Word1"], output.metas.flatten())
self.assertTupleEqual(
Expand Down Expand Up @@ -168,6 +169,14 @@ def test_select_words_output(self):
self.assertEqual(2, len(output))
self.assertEqual("words", output.domain["Words"].attributes["type"])

def test_word_counts_output(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)
output = self.get_output(self.widget.Outputs.word_counts)
words = set(w for doc in list(self.corpus.ngrams) for w in doc)
self.assertEqual(len(words), len(output))
self.assertLessEqual(output.X[:, 1][0], len(self.corpus))
self.assertEqual(len(output.domain), 3)


if __name__ == "__main__":
unittest.main()

0 comments on commit 43f24cd

Please sign in to comment.