def test_sentences(self): data = StringIO(self.data) sentences = list(webap.get_sentences(data)) self.assertEqual(len(sentences), 5) self.assertListEqual([s[0] for s in sentences], self.texts_truth) for s in sentences: self.assertItemsEqual(s[1], ('id', 'rel', 'qid', 'docno', 'original_docno')) self.assertListEqual([s[1]['id'] for s in sentences], [str(i) for i in range(1, 6)]) self.assertListEqual([s[1]['rel'] for s in sentences], [str(i) for i in range(5)]) def all_the_same(l): return len(l) == 0 or l.count(l[0]) == len(l) self.assertTrue(all_the_same([s[1]['qid'] for s in sentences])) self.assertTrue(all_the_same([s[1]['docno'] for s in sentences])) self.assertTrue(all_the_same([s[1]['original_docno'] for s in sentences]))
def test_sentences(self): data = StringIO(self.data) sentences = list(webap.get_sentences(data)) self.assertEqual(len(sentences), 5) self.assertListEqual([s[0] for s in sentences], self.texts_truth) for s in sentences: self.assertItemsEqual( s[1], ('id', 'rel', 'qid', 'docno', 'original_docno')) self.assertListEqual([s[1]['id'] for s in sentences], [str(i) for i in range(1, 6)]) self.assertListEqual([s[1]['rel'] for s in sentences], [str(i) for i in range(5)]) def all_the_same(l): return len(l) == 0 or l.count(l[0]) == len(l) self.assertTrue(all_the_same([s[1]['qid'] for s in sentences])) self.assertTrue(all_the_same([s[1]['docno'] for s in sentences])) self.assertTrue( all_the_same([s[1]['original_docno'] for s in sentences]))
def test_get_sentences(self): data = StringIO(self.data) self.assertEqual(len(list(webap.get_sentences(data))), 0)