MCPcopy
hub / github.com/SqueezeAILab/LLMCompiler / normalize_answer

Function normalize_answer

src/utils/evaluation_utils.py:8–22  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

6
7
8def normalize_answer(s):
9 def remove_articles(text):
10 return re.sub(r"\b(a|an|the)\b", " ", text)
11
12 def white_space_fix(text):
13 return " ".join(text.split())
14
15 def remove_punc(text):
16 exclude = set(string.punctuation)
17 return "".join(ch for ch in text if ch not in exclude)
18
19 def lower(text):
20 return text.lower()
21
22 return white_space_fix(remove_articles(remove_punc(lower(s))))
23
24
25def run_and_time(func, *args, **kwargs):

Callers 2

mainFunction · 0.90
compare_answerFunction · 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