MCPcopy Create free account
hub / github.com/EternityJune25/ComoRAG / normalize_answer

Function normalize_answer

script/eval_qa.py:15–33  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

13 return logging.getLogger(name)
14
15def normalize_answer(s):
16
17 import re
18 import string
19
20 def remove_articles(text):
21 return re.sub(r'\b(a|an|the)\b', ' ', text)
22
23 def white_space_fix(text):
24 return ' '.join(text.split())
25
26 def remove_punc(text):
27 exclude = set(string.punctuation)
28 return ''.join(ch for ch in text if ch not in exclude)
29
30 def lower(text):
31 return text.lower()
32
33 return white_space_fix(remove_articles(remove_punc(lower(s))))
34
35class QAExactMatch:
36 metric_name: str = "qa_exact_match"

Callers 2

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