def test_words_on_sentence_without_word_elements(self): sentence = Sentence([ EmptyNode(main_index=0, sub_index=1), Multiword(first_index=1, last_index=2), ]) result = sentence.words() self.assertIsInstance(result, Generator) self.assertEqual([], list(result))
def test_words_on_sentence_wit_mixed_element(self): expected = [Word(index=1), Word(index=2), Word(index=3), Word(index=4)] sentence = Sentence([ Multiword(first_index=1, last_index=2), expected[0], # 1 expected[1], # 2 EmptyNode(main_index=2, sub_index=1), EmptyNode(main_index=2, sub_index=2), Multiword(first_index=3, last_index=4), expected[2], # 3 expected[3], # 4 ]) result = sentence.words() self.assertIsInstance(result, Generator) self.assertEqual(expected, list(result))
def test_words_on_empty_sentence(self): sentence = Sentence() result = sentence.words() self.assertIsInstance(result, Generator) self.assertEqual([], list(result))