Normalize answer.
(s)
| 21 | |
| 22 | |
| 23 | def normalize_answer(s): |
| 24 | """Normalize answer.""" |
| 25 | s = unicodedata.normalize("NFD", s) |
| 26 | |
| 27 | def remove_articles(text): |
| 28 | return re.sub(r"\b(a|an|the)\b", " ", text) |
| 29 | |
| 30 | def white_space_fix(text): |
| 31 | return " ".join(text.split()) |
| 32 | |
| 33 | def remove_punc(text): |
| 34 | exclude = set(string.punctuation) |
| 35 | return "".join(ch for ch in text if ch not in exclude) |
| 36 | |
| 37 | def lower(text): |
| 38 | return text.lower() |
| 39 | |
| 40 | return white_space_fix(remove_articles(remove_punc(lower(s)))) |
| 41 | |
| 42 | |
| 43 | def exact_match_score(prediction, ground_truth): |
no test coverage detected