MCPcopy Create free account
hub / github.com/InternScience/SciReason / normalize_zh_answer

Function normalize_zh_answer

opencompass/datasets/longbench/evaluators.py:34–50  ·  view source on GitHub ↗

Lower text and remove punctuation, extra whitespace.

(s)

Source from the content-addressed store, hash-verified

32
33
34def 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()

Callers 1

scoreMethod · 0.70

Calls 3

white_space_fixFunction · 0.70
remove_puncFunction · 0.70
lowerFunction · 0.70

Tested by

no test coverage detected