OpenCompass/opencompass/datasets/PMMEval/mifeval_utils/punctuation_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
710 B
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
comma_unicode = {
'ar': re.compile(r'[\u060C]'),
'es': re.compile(r'[,\uFF0C]'),
'fr': re.compile(r'[,\u2026]'),
'ja': re.compile(r'[,\u3001]'),
'ko': re.compile(r'[,]'),
'pt': re.compile(r'[,\uFF0C]'),
'th': re.compile(r'[\u0E25]'),
'vi': re.compile(r'[,\uFF0C]'),
'en': re.compile(r'[,]'),
'zh': re.compile(r'[,]')
}
def no_comma_checker(input_string: str, lang_code: str, **kwargs):
if len(comma_unicode[lang_code].findall(input_string)) > 0:
return False
else:
return True
punctuation_checker = {
'no_comma': {
'function': no_comma_checker,
'required_lang_code': True,
'num_of_params': 2
}
}