Lower text and remove punctuation, extra whitespace.
(s)
| 32 | |
| 33 | |
| 34 | def normalize_zh_answer(s): |
| 35 | """Lower text and remove punctuation, extra whitespace.""" |
| 36 | |
| 37 | def white_space_fix(text): |
| 38 | return ''.join(text.split()) |
| 39 | |
| 40 | def remove_punc(text): |
| 41 | cn_punctuation = '!?。。"#$%&'()*+,-/:;<=>@[\]^_`\ |
| 42 | {|}~⦅⦆「」、、〃》「」『』【】〔〕〖〗〘〙〚〛〜〝〞〟〰〾〿–—‘’‛“”„‟…‧﹏.' |
| 43 | |
| 44 | all_punctuation = set(string.punctuation + cn_punctuation) |
| 45 | return ''.join(ch for ch in text if ch not in all_punctuation) |
| 46 | |
| 47 | def lower(text): |
| 48 | return text.lower() |
| 49 | |
| 50 | return white_space_fix(remove_punc(lower(s))) |
| 51 | |
| 52 | |
| 53 | @ICL_EVALUATORS.register_module() |
no test coverage detected