MCPcopy Create free account
hub / github.com/OrangeInSouth/DeePEn / normalize_answer

Function normalize_answer

utils/evaluate/utils/eval_utils.py:23–40  ·  view source on GitHub ↗

Normalize answer.

(s)

Source from the content-addressed store, hash-verified

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

Callers 1

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