Lower text and remove punctuation, articles and extra whitespace.
(s)
| 15 | |
| 16 | |
| 17 | def normalize_answer(s): |
| 18 | """Lower text and remove punctuation, articles and extra whitespace.""" |
| 19 | |
| 20 | def remove_articles(text): |
| 21 | return re.sub(r'\b(a|an|the)\b', ' ', text) |
| 22 | |
| 23 | def white_space_fix(text): |
| 24 | return ' '.join(text.split()) |
| 25 | |
| 26 | def remove_punc(text): |
| 27 | exclude = set(string.punctuation) |
| 28 | return ''.join(ch for ch in text if ch not in exclude) |
| 29 | |
| 30 | def lower(text): |
| 31 | return unidecode.unidecode(text.lower()) |
| 32 | |
| 33 | return white_space_fix(remove_articles(remove_punc(lower(s)))) |
| 34 | |
| 35 | |
| 36 | def f1_score(prediction, ground_truth): |
no test coverage detected