def test_get_random_contrastive_word_boundaries(self): rewrite = contrastive_statements.Rewriter() candidate = ContrastiveCandidate( text='Peter was born on 24 April 1950.', focus_texts={'95', '24 Ap', '4 April'}, positive_replacement_texts={'24 April 1950'}, negative_replacement_texts={'25 April 1950'}, support_texts={'Peter'}) texts = set() for i in range(10): rng = random.Random(i) texts.add( rewrite.get_random_contrastive_statement( rng, candidate, candidate.text)) self.assertEqual(texts, {None})
def test_get_random_contrastive_statement_no_focus(self): rewrite = contrastive_statements.Rewriter() candidate = ContrastiveCandidate( text='Robert was born on 24 May 1950.', focus_texts={'24 April 1950'}, positive_replacement_texts={'24 April 1950'}, negative_replacement_texts={'24 March 1950', '24 April 1951'}, support_texts={'Robert'}) texts = set() for i in range(10): rng = random.Random(i) texts.add( rewrite.get_random_contrastive_statement( rng, candidate, candidate.text)) self.assertEqual(texts, {None})