(response)
| 337 | return string[left_brace_idx + 1: right_brace_idx].strip() |
| 338 | |
| 339 | def match_answer(response): |
| 340 | is_matched = False |
| 341 | # for ans_marker in ['answer:', "answer is", "answers are"]: |
| 342 | # ans_idx = response.lower().rfind(ans_marker) |
| 343 | # if ans_idx != -1: |
| 344 | # is_matched = True |
| 345 | # response = response[ans_idx + len(ans_marker):].strip() |
| 346 | # if response.endswith("\n"): |
| 347 | # response = response[:-2] |
| 348 | |
| 349 | # for ans_marker in ["is answer", "is the answer", "are answers", "are the answers"]: |
| 350 | # ans_idx = response.lower().rfind(ans_marker) |
| 351 | # if ans_idx != -1: |
| 352 | # is_matched = True |
| 353 | # response = response[:ans_idx].strip() |
| 354 | # if response.endswith("\n"): |
| 355 | # response = response[:-2] |
| 356 | |
| 357 | # Find boxed |
| 358 | ans_boxed = _last_boxed_only_string(response) |
| 359 | if ans_boxed: |
| 360 | is_matched = True |
| 361 | response = ans_boxed |
| 362 | |
| 363 | # if ". " in response: |
| 364 | # dot_idx = response.lower().rfind(". ") |
| 365 | # if dot_idx != -1: |
| 366 | # response = response[:dot_idx].strip() |
| 367 | |
| 368 | # for ans_marker in ['be ', "is ", "are ", "=", ": ", "get ", 'be\n', "is\n", "are\n", ":\n", "get\n"]: |
| 369 | # ans_idx = response.lower().rfind(ans_marker) |
| 370 | # if ans_idx != -1: |
| 371 | # is_matched = True |
| 372 | # response = response[ans_idx + len(ans_marker):].strip() |
| 373 | # if response.endswith("\n"): |
| 374 | # response = response[:-2] |
| 375 | |
| 376 | is_matched = is_matched if any([c.isdigit() for c in response]) else False # answer must have a digit |
| 377 | # Grade |
| 378 | return is_matched, response |
| 379 | |
| 380 | |
| 381 | import math |
no test coverage detected