def test_normalize_squad(self): self.assertEqual( qa_utils.normalize_squad( "`Needs\tA_LOT of the 'normalization'.\"‘"), "needs alot of normalization‘", ) self.assertEqual( qa_utils.normalize_squad("needs no normalization"), "needs no normalization", )
def squad(targets, predictions): """Computes SQuAD metrics, maximizing over answers per question. Args: targets: list of lists of strings predictions: list of strings Returns: dict with score_key: squad score across all targets and predictions """ targets = [[qa_utils.normalize_squad(t) for t in u] for u in targets] predictions = [qa_utils.normalize_squad(p) for p in predictions] return qa_utils.qa_metrics(targets, predictions)