def test_from_word_lists(self): word_lists = [[BasicWord('hi')], [BasicWord('ho')]] tags = Tags([StatusTag.RAW]) paragraph = Paragraph.from_word_lists(word_lists, tags) self.assertEqual(paragraph.sentence_list(), [Sentence(lst) for lst in word_lists]) self.assertEqual(paragraph.tags, tags) paragraph = Paragraph.from_word_lists(word_lists) self.assertEqual(paragraph.sentence_list(), [Sentence(lst) for lst in word_lists]) self.assertEqual(paragraph.tags, Tags())
def test_find(self): paragraph = Paragraph.from_word_lists([ [BasicWord('x'), BasicWord('y')], [BasicWord('z'), BasicWord('y'), BasicWord('x')], [BasicWord('q')] ]) self.assertEqual(paragraph.find(BasicWord('x')), [(0, 0), (1, 2)])
def test_find_word_not_present(self): paragraph = Paragraph.from_word_lists([[BasicWord('x')]]) self.assertEqual(paragraph.find(BasicWord('y')), [])
def test_set_index_error(self): paragraph = Paragraph.from_word_lists([[BasicWord('test')]]) self.assertRaises(IndexError, paragraph.set, 10, 0, BasicWord('x')) self.assertRaises(IndexError, paragraph.set, 0, 10, BasicWord('x'))