(pred_str, ans_str)
| 30 | return a |
| 31 | |
| 32 | def test_answer(pred_str, ans_str): |
| 33 | if('The answer is ' in pred_str): |
| 34 | pred = pred_str.split('The answer is ')[-1].strip() |
| 35 | else: |
| 36 | pattern = '\d*\.?\d+' |
| 37 | pred = re.findall(pattern, pred_str) |
| 38 | if(len(pred) >= 1): |
| 39 | # print(pred_str) |
| 40 | pred = pred[-1] |
| 41 | else: pred = '' |
| 42 | |
| 43 | gold = find_answer(ans_str) |
| 44 | # gold = re.findall(pattern, ans_str) |
| 45 | # print(ans_str) |
| 46 | # gold = gold[-1] |
| 47 | # print('pred:', pred) |
| 48 | # print('gold:', gold) |
| 49 | # print('---\n\n') |
| 50 | return pred == gold |
| 51 | |
| 52 | def parse_pred_ans(filename): |
| 53 | with open(filename) as fd: lines = fd.readlines() |
no test coverage detected