Exemple #1
0
    def test_get_representative_vectors_from_empty_cluster(self):
        """
        Test that when getting the representative vectors from an empty cluster, an empty list is returned.
        """

        c = Cluster()
        self.assertEqual(list, type(c.get_representative_vectors(2)))
        self.assertEqual([], c.get_representative_vectors(2))
Exemple #2
0
    def test_get_representative_vectors(self):
        """
        Test ranking the vectors according to their similarity to the cluster.
        """

        v = [
            Document("", ['a', 'b', 'c'], scheme=TF()),
            Document("", ['a', 'a', 'c'], scheme=TF()),
            Document("", ['p'], scheme=TF()),
        ]
        c = Cluster(v)
        self.assertEqual(list, type(c.get_representative_vectors(2)))
        self.assertEqual([v[1], v[0]], c.get_representative_vectors(2))
Exemple #3
0
    def test_get_representative_vector_from_empty_cluster(self):
        """
        Test that when getting the representative vector from an empty cluster, ``None`` is returned.
        """

        c = Cluster()
        self.assertEqual(None, c.get_representative_vectors(1))