MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / normalize_answer

Function normalize_answer

eval_heldout/rewoo/utils/Evaluator.py:21–35  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

19
20
21def normalize_answer(s):
22 def remove_articles(text):
23 return re.sub(r"\b(a|an|the)\b", " ", text)
24
25 def white_space_fix(text):
26 return " ".join(text.split())
27
28 def remove_punc(text):
29 exclude = set(string.punctuation)
30 return "".join(ch for ch in text if ch not in exclude)
31
32 def lower(text):
33 return text.lower()
34
35 return white_space_fix(remove_articles(remove_punc(lower(s))))
36
37
38def f1_score(prediction, ground_truth):

Callers 2

f1_scoreFunction · 0.70
get_metricsMethod · 0.70

Calls 4

white_space_fixFunction · 0.70
remove_articlesFunction · 0.70
remove_puncFunction · 0.70
lowerFunction · 0.70

Tested by

no test coverage detected