OpenCompass/opencompass/datasets/PMMEval/mifeval_utils/detectable_content_checker.py
wanyu2018umac 90efcf2216
[Feature] Add P-MMEval (#1714)
* Update with PMMEval

* Update

* Update __init__.py

* Fix Bugs

* Delete .pre-commit-config.yaml

* Pull merge

---------

Co-authored-by: liushz <qq1791167085@163.com>
2024-11-27 21:26:18 +08:00

31 lines
915 B
Python
Executable File

import re
def number_placeholders_checker(input_string: str, num_placeholders: int,
**kwargs):
placeholders = re.findall(r'\[.*?\]', input_string)
return len(placeholders) >= num_placeholders
def postscript_checker(input_string: str, postscript_marker: str, **kwargs):
input_string = input_string.lower()
postscript_pattern = r'\s*' + postscript_marker.lower() + r'.*$'
postscript = re.findall(postscript_pattern,
input_string,
flags=re.MULTILINE)
return True if postscript else False
detectable_content_checker = {
'number_placeholders': {
'function': number_placeholders_checker,
'required_lang_code': False,
'num_of_params': 2
},
'postscript': {
'function': postscript_checker,
'required_lang_code': False,
'num_of_params': 2
}
}