MCPcopy
hub / github.com/Tele-AI/Telechat / extract_answer_option

Function extract_answer_option

evaluation/score_CEVAL.py:80–122  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

78 return f"{question}\n{choice}\n答案:{answer}"
79
80def extract_answer_option(text):
81 patterns = [
82 "答案是?\s?([ABCD])",
83 "答案是?\s?:([ABCD])",
84 "答案是?\s?:([ABCD])",
85 "答案应该?是\s?([ABCD])",
86 "答案应该?选\s?([ABCD])",
87 "答案为\s?([ABCD])",
88 "选择\s?([ABCD])",
89 "只有选?项?\s?([ABCD])\s?是?对",
90 "只有选?项?\s?([ABCD])\s?是?错",
91 "只有选?项?\s?([ABCD])\s?不?正确",
92 "只有选?项?\s?([ABCD])\s?错误",
93 "说法不?对选?项?的?是\s?([ABCD])",
94 "说法不?正确选?项?的?是\s?([ABCD])",
95 "说法错误选?项?的?是\s?([ABCD])",
96 "([ABCD])\s?是正确的",
97 "([ABCD])\s?是正确答案",
98 "选项\s?([ABCD])\s?正确",
99 "所以答\s?([ABCD])",
100 "1.\s?([ABCD])[.。$]?$",
101 "所以\s?([ABCD][.。$]?$)",
102 "所有\s?([ABCD][.。$]?$)",
103 "[\s,::,]([ABCD])[。,,\.]?$",
104 "[\s,,::][故即]([ABCD])[。\.]?$",
105 "[\s,,::]因此([ABCD])[。\.]?$",
106 "[是为。]\s?([ABCD])[。\.]?$",
107 "因此\s?([ABCD])[。\.]?$",
108 "显然\s?([ABCD])[。\.]?$",
109 "1.\s?(.*?)$",
110 "答案是\s?(\S+)(?:。|$)",
111 "答案应该是\s?(\S+)(?:。|$)",
112 "答案为\s?(\S+)(?:。|$)",
113 ]
114
115 regexes = [re.compile(pattern) for pattern in patterns]
116 for regex in regexes:
117 match = regex.search(text)
118 if match:
119 return match.group(1)
120 for i in text:
121 if i in "ABCD": return i
122 return "C"
123
124def get_args():
125 parser = argparse.ArgumentParser(

Callers 1

score_CEVAL.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected