diff --git a/gensim/test/test_BM25.py b/gensim/test/test_BM25.py index f9fc28d35b..b6575cddb2 100644 --- a/gensim/test/test_BM25.py +++ b/gensim/test/test_BM25.py @@ -16,35 +16,33 @@ class TestBM25(unittest.TestCase): - - def test_max_match_with_itself(self) : - """ Document should show maximum matching with itself """ - weights = get_bm25_weights(common_texts) - for index,doc_weights in enumerate(weights) : - expected = max(doc_weights) - predicted = doc_weights[index] - self.assertEqual(expected , predicted) - - def test_nonnegative_weights(self): - """ All the weights for a partiular document should be non negative """ - weights = get_bm25_weights(common_texts) - self.assertTrue(min(weights)>=0) - - def test_same_match_with_same_document(self): - """ A document should always get the same weight when matched with a particular document """ - corpus = [['cat','dog','mouse'] , ['cat','lion'] , ['cat','lion']] - weights = get_bm25_weights(corpus) - self.assertEqual(weights[0][1],weights[0][2]) - - def test_disjoint_docs_if_weight_zero(self): - """ Two disjoint documents should have zero matching""" - corpus = [['cat','dog','lion'] , ['goat','fish','tiger']] - weights = get_bm25_weights(corpus) - self.assertTrue(weights[0][1]==0) - self.assertTrue(weights[1][0]==0) - -if __name__ == '__main__': - logging.basicConfig(level=logging.DEBUG) - unittest.main() + def test_max_match_with_itself(self): + """ Document should show maximum matching with itself """ + weights = get_bm25_weights(common_texts) + for index, doc_weights in enumerate(weights): + expected = max(doc_weights) + predicted = doc_weights[index] + self.assertEqual(expected, predicted) + + def test_nonnegative_weights(self): + """ All the weights for a partiular document should be non negative """ + weights = get_bm25_weights(common_texts) + self.assertTrue(min(weights) >= 0) + + def test_same_match_with_same_document(self): + """ A document should always get the same weight when matched with a particular document """ + corpus = [['cat', 'dog', 'mouse'], ['cat', 'lion'], ['cat', 'lion']] + weights = get_bm25_weights(corpus) + self.assertEqual(weights[0][1], weights[0][2]) + + def test_disjoint_docs_if_weight_zero(self): + """ Two disjoint documents should have zero matching""" + corpus = [['cat', 'dog', 'lion'], ['goat', 'fish', 'tiger']] + weights = get_bm25_weights(corpus) + self.assertTrue(weights[0][1] == 0) + self.assertTrue(weights[1][0] == 0) +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + unittest.main()