def test_cos_e_multi_word_answer(self): self.assertEqual( postprocessors.abstractive_explanations( output="goodnight moon explanation: it's a popular kids book.", example=None, is_target=True), { "label": "goodnight moon", "explanations": ["it's a popular kids book."] })
def test_cos_e_explanation_contains_because(self): self.assertEqual( postprocessors.abstractive_explanations( output="cheeseburger explanation: because she was hungry.", example=None, is_target=True), { "label": "cheeseburger", "explanations": ["because she was hungry."] })
def test_cos_e(self): self.assertEqual( postprocessors.abstractive_explanations( output="cheeseburger explanation: she ordered a cheeseburger.", example=None, is_target=True), { "label": "cheeseburger", "explanations": ["she ordered a cheeseburger."] })
def test_esnli_multiple_explanations(self): self.assertEqual( postprocessors.abstractive_explanations( "entailment explanation: this is correct. " "explanation: correct. explanation: also correct.", example=None, is_target=False), { "label": "entailment", "explanations": ["this is correct.", "correct.", "also correct."] })
def test_esnli(self): self.assertEqual( postprocessors.abstractive_explanations( "entailment explanation: this is correct.", example=None, is_target=False), { "label": "entailment", "explanations": ["this is correct."] }) self.assertEqual( postprocessors.abstractive_explanations( "entailment explanation: this is correct.", example={ "inputs_plaintext": b"This is incorrect", "targets_plaintext": b"Incorrect answer." }, is_target=True), { "label": "entailment", "explanations": ["this is correct."] })
def test_movies(self): self.assertEqual( postprocessors.abstractive_explanations( "negative explanation: the movie was boring explanation: acting " "was bad explanation: poor script explanation: skip it.", separator=" explanation: "), { "label": "negative", "explanations": [ "the movie was boring", "acting was bad", "poor script", "skip it." ] })