예제 #1
0
파일: tests.py 프로젝트: sankosk/SIW
 def test_document_len(self):
     bag1 = BagOfWords("cat dog cow fish cat cat fish")
     bag2 = BagOfWords("dog grape banana peach")
     self.assertEqual(bag1.document_len(), 7)
     self.assertEqual(bag2.document_len(), 4)
     self.assertEqual(bag1.intersection(bag2).document_len(), 1)
     self.assertEqual(bag1.union(bag2).document_len(), 11)
예제 #2
0
    def test_document_len(self):
        """Prueba el tamaño del documento, no del vector
        """
        bag1 = BagOfWords("cat dog cow fish cat cat fish")
        bag2 = BagOfWords("dog grape banana peach")

        self.assertEqual(bag1.document_len(), 7)
        self.assertEqual(bag2.document_len(), 4)
        self.assertEqual(bag1.intersection(bag2).document_len(), 1)
        self.assertEqual(bag1.union(bag2).document_len(), 11)
예제 #3
0
파일: tests.py 프로젝트: sankosk/SIW
 def test_union(self):
     bag1 = BagOfWords("cat dog cow fish cat cat fish")
     bag2 = BagOfWords("dog grape banana peach")
     self.assertDictEqual(
         bag1.union(bag2).values, {
             "banana": 1,
             "cat": 3,
             "cow": 1,
             "dog": 2,
             "fish": 2,
             "grape": 1,
             "peach": 1
         })