MCPcopy
hub / github.com/zai-org/GLM-130B / normalize_answer

Function normalize_answer

evaluation/metrics.py:56–72  ·  view source on GitHub ↗

Lower text and remove punctuation, articles and extra whitespace.

(s)

Source from the content-addressed store, hash-verified

54
55
56def 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
75def f1_score(prediction, ground_truth):

Callers 2

f1_scoreFunction · 0.85
exact_match_scoreFunction · 0.85

Calls 4

white_space_fixFunction · 0.85
remove_articlesFunction · 0.85
remove_puncFunction · 0.85
lowerFunction · 0.85

Tested by

no test coverage detected