(sentence)
| 101 | |
| 102 | |
| 103 | def parse_float_answer(sentence): |
| 104 | # Correctly apply remove_formula to the sentence |
| 105 | sentence = remove_formula(sentence) |
| 106 | |
| 107 | # First, look for formatted answer:number (case-insensitive, no spaces) |
| 108 | processed_string = sentence.lower().replace(" ", "") |
| 109 | answer_matches = re.findall(r'answer:(-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?)', processed_string) |
| 110 | if answer_matches: |
| 111 | try: |
| 112 | return verify_float(float(answer_matches[-1])) |
| 113 | except ValueError: |
| 114 | pass |
| 115 | |
| 116 | # Then find all scientific notation numbers, take the last one |
| 117 | sci_matches = re.findall(r'-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?', sentence) |
| 118 | if sci_matches: |
| 119 | try: |
| 120 | return verify_float(float(sci_matches[-1])) |
| 121 | except ValueError: |
| 122 | pass |
| 123 | |
| 124 | # Lastly, find all regular floats, take the last one |
| 125 | float_matches = re.findall(r'-?\d+(?:\.\d+)?', sentence) |
| 126 | if float_matches: |
| 127 | try: |
| 128 | return verify_float(float(float_matches[-1])) |
| 129 | except ValueError: |
| 130 | pass |
| 131 | |
| 132 | # If no valid number found, return 0.0 |
| 133 | return 0.0 |
| 134 | |
| 135 | |
| 136 | def parse_true_false_answer(raw_string, option=''): |
no test coverage detected