MCPcopy Create free account
hub / github.com/SkyworkAI/Skywork / extract_answer

Function extract_answer

eval/eval_gsm8k.py:74–91  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

72 return INVALID_ANS
73
74def extract_answer(text):
75 if prefix_sky1 in text:
76 text = text.split(prefix_sky1)[-1]
77 if prefix_sky2 in text:
78 text = text.split(prefix_sky2)[-1]
79 match1 = re.findall(ans_re1, text)
80 match2 = re.findall(ans_re2, text)
81 ans = []
82 if match1:
83 match_str1 = get_match_str(match1, -1)
84 ans.append(match_str1)
85 if match2:
86 match_str2 = get_match_str(match2, -1).replace('$','')
87 ans.append(match_str2)
88 if len(ans) > 0:
89 return eval(ans[-1])
90 else:
91 return INVALID_ANS
92
93def is_correct(completion, answer):
94 completion = completion.split('</s>')[0]

Callers 1

is_correctFunction · 0.85

Calls 1

get_match_strFunction · 0.85

Tested by

no test coverage detected