MCPcopy Create free account
hub / github.com/google-research/language / normalize_answer

Function normalize_answer

language/orqa/utils/eval_utils.py:25–42  ·  view source on GitHub ↗

Normalize answer.

(s)

Source from the content-addressed store, hash-verified

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

Callers 1

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…