| 23 | |
| 24 | |
| 25 | def 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 | |
| 40 | def extract_ans(ans_num, output_path, cot_flag): |