mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00

* add support for matbench * fix dataset path * fix data load * fix * fix lint --------- Co-authored-by: Jucheng Hu <jucheng.hu.20@ucl.ac.uk> Co-authored-by: Myhs-phz <demarcia2014@126.com>
26 lines
603 B
Python
26 lines
603 B
Python
# flake8: noqa
|
|
|
|
import re
|
|
|
|
|
|
def parse_float_answer(raw_string, option=''):
|
|
number_pattern = re.compile(r'[-+]?\d+(\.\d+)?([eE][-+]?\d+)?')
|
|
|
|
# Search for the first match
|
|
match = number_pattern.search(raw_string)
|
|
if match:
|
|
# Extract the matched number and convert it to float
|
|
return float(match.group())
|
|
else:
|
|
# Return None if no number is found
|
|
return 0
|
|
|
|
|
|
def parse_true_false_answer(raw_string, option=''):
|
|
if 'yes' in raw_string.lower():
|
|
return True
|
|
elif 'no' in raw_string.lower():
|
|
return False
|
|
else:
|
|
return True
|