MCPcopy Index your code
hub / github.com/algorithmicsuperintelligence/optillm / normalize_answer

Function normalize_answer

scripts/eval_imobench_answer.py:70–88  ·  view source on GitHub ↗

Normalize answer for comparison

(answer: str)

Source from the content-addressed store, hash-verified

68
69
70def normalize_answer(answer: str) -> str:
71 """
72 Normalize answer for comparison
73 """
74 if answer is None:
75 return ""
76
77 # Convert to string and lowercase
78 answer = str(answer).strip().lower()
79
80 # Remove extra whitespace
81 answer = re.sub(r'\s+', ' ', answer)
82
83 # Remove common LaTeX formatting
84 answer = answer.replace('\\', '')
85 answer = answer.replace('$', '')
86 answer = answer.replace('{', '').replace('}', '')
87
88 return answer
89
90
91def compare_answers(predicted: str, ground_truth: str) -> bool:

Callers 1

compare_answersFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected