def test_indexed_all_words(self): sentence_one = [BasicWord('hi'), BasicWord('there'), BasicWord('guy')] sentence_two = [BasicWord('ho'), BasicWord('there')] paragraph = Paragraph([Sentence(sentence_one), Sentence(sentence_two)]) all_sentences = [sentence_one, sentence_two] for s_index, w_index, word in paragraph.indexed_all_words(): self.assertEqual(word, all_sentences[s_index][w_index])
def assign_random_negatives(paragraph: Paragraph, p_negative) -> Paragraph: out = paragraph for s_index, w_index, word in paragraph.indexed_all_words(): if isinstance(word, Verb) and random.random() < p_negative: out = out.set(s_index, w_index, word.negative()) return out.set_tags(paragraph.tags.add(StatusTag.HAS_NEGATIVES))