MCPcopy Create free account
hub / github.com/FreedomIntelligence/CMB / match_choice

Function match_choice

src/utils.py:25–37  ·  view source on GitHub ↗
(text, cot_flag)

Source from the content-addressed store, hash-verified

23
24
25def match_choice(text, cot_flag):
26 if cot_flag:
27 option = ["A", "B", "C", "D", "E", "F", "G"]
28 res = re.search(r"(答案|正确选项)(?:是|:|为|应该是|应该为)(.*?)(。|\.|$)", text, re.S)
29 if res:
30 return "".join([x for x in res.group(2) if x in option])
31 return "".join([i for i in text if i in option])
32 else:
33 option = ["A", "B", "C", "D", "E", "F", "G"]
34 res = re.search(r"(答案|正确选项)(?:是|:|为|应该是|应该为)(.*?)(。|\.|$)", text, re.S)
35 if res:
36 return "".join([x for x in res.group(2) if x in option])
37 return "".join([i for i in text if i in option])
38
39
40def extract_ans(ans_num, output_path, cot_flag):

Callers 1

extract_ansFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected