Lower text and remove punctuation, articles and extra whitespace.
(s)
| 54 | |
| 55 | |
| 56 | def normalize_answer(s): |
| 57 | """Lower text and remove punctuation, articles and extra whitespace.""" |
| 58 | |
| 59 | def remove_articles(text): |
| 60 | return re.sub(r"\b(a|an|the)\b", " ", text) |
| 61 | |
| 62 | def white_space_fix(text): |
| 63 | return " ".join(text.split()) |
| 64 | |
| 65 | def remove_punc(text): |
| 66 | exclude = set(string.punctuation) |
| 67 | return "".join(ch for ch in text if ch not in exclude) |
| 68 | |
| 69 | def lower(text): |
| 70 | return text.lower() |
| 71 | |
| 72 | return white_space_fix(remove_articles(remove_punc(lower(s)))) |
| 73 | |
| 74 | |
| 75 | def f1_score(prediction, ground_truth): |
no test coverage detected