(response)
| 91 | return string[left_brace_idx + 1: right_brace_idx].strip() |
| 92 | |
| 93 | def match_answer(response): |
| 94 | is_matched = False |
| 95 | |
| 96 | ans_marker = 'the answer is: ' |
| 97 | ans_idx = response.lower().rfind(ans_marker) |
| 98 | if ans_idx != -1: |
| 99 | is_matched = True |
| 100 | response = response[ans_idx + len(ans_marker):].strip() |
| 101 | if response.endswith("\n"): |
| 102 | response = response[:-2] |
| 103 | |
| 104 | ans_marker = 'answer:\n' |
| 105 | ans_idx = response.lower().rfind(ans_marker) |
| 106 | if ans_idx != -1: |
| 107 | is_matched = True |
| 108 | response = response[ans_idx + len(ans_marker):].strip() |
| 109 | if response.endswith("\n"): |
| 110 | response = response[:-2] |
| 111 | |
| 112 | ans_marker = 'answer: ' |
| 113 | ans_idx = response.lower().rfind(ans_marker) |
| 114 | if ans_idx != -1: |
| 115 | is_matched = True |
| 116 | response = response[ans_idx + len(ans_marker):].strip() |
| 117 | if response.endswith("\n"): |
| 118 | response = response[:-2] |
| 119 | |
| 120 | # Find boxed |
| 121 | ans_boxed = _last_boxed_only_string(response) |
| 122 | if ans_boxed: |
| 123 | is_matched = True |
| 124 | response = ans_boxed |
| 125 | |
| 126 | # Grade |
| 127 | return is_matched, response |
| 128 | |
| 129 | ANS_RE = re.compile(r"#### (\-?[0-9\.\,]+)") |
| 130 | INVALID_ANS = "[invalid]" |
no test coverage detected