Пример #1
0
 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_intersection(self):
     bag1 = BagOfWords("cat dog cow fish cat cat fish")
     bag2 = BagOfWords("dog grape banana peach")
     self.assertDictEqual(bag1.intersection(bag2).values, {"dog": 1})