MCPcopy Create free account
hub / github.com/RUC-NLPIR/WebThinker / normalize_answer_qa

Function normalize_answer_qa

scripts/evaluate/evaluate.py:185–195  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

183
184 if mode in ['qa']:
185 def normalize_answer_qa(s):
186 def remove_articles(text):
187 return re.sub(r"\b(a|an|the)\b", " ", text)
188 def white_space_fix(text):
189 return " ".join(text.strip().split())
190 def remove_punc(text):
191 exclude = set(string.punctuation)
192 return "".join(ch for ch in text if ch not in exclude)
193 def lower(text):
194 return text.lower()
195 return white_space_fix(remove_articles(remove_punc(lower(s))))
196 normalized_pred_answer = normalize_answer_qa(pred_answer_new)
197
198 for answer in labeled_answer:

Callers 1

evaluate_predictionsFunction · 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