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

Function normalize_answer

eval_heldout/hotpotQA/src/agent_arch.py:62–76  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

60 return '\n'.join(lines)
61
62def normalize_answer(s):
63 def remove_articles(text):
64 return re.sub(r"\b(a|an|the)\b", " ", text)
65
66 def white_space_fix(text):
67 return " ".join(text.split())
68
69 def remove_punc(text):
70 exclude = set(string.punctuation)
71 return "".join(ch for ch in text if ch not in exclude)
72
73 def lower(text):
74 return text.lower()
75
76 return white_space_fix(remove_articles(remove_punc(lower(s))))
77
78def f1_score(prediction, ground_truth):
79 normalized_prediction = normalize_answer(prediction)

Callers 2

f1_scoreFunction · 0.70
EMFunction · 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