diff --git a/qlib/utils/__init__.py b/qlib/utils/__init__.py index 8852155bc..de60b18b7 100644 --- a/qlib/utils/__init__.py +++ b/qlib/utils/__init__.py @@ -274,9 +274,11 @@ def parse_field(field): if not isinstance(field, str): field = str(field) + # Chinese Punctuation Regex: \nff08 = (, \nff09 = ), \nff1a = :, \n3001 = 。 + chinese_punctuation_regex = r"\u3001\uff1a\uff08\uff09" for pattern, new in [ - (r"\$\$(\w+)", r'PFeature("\1")'), # $$ must be before $ - (r"\$(\w+)", rf'Feature("\1")'), + (rf"\$\$([\w{chinese_punctuation_regex}]+)", r'PFeature("\1")'), # $$ must be before $ + (rf"\$([\w{chinese_punctuation_regex}]+)", r'Feature("\1")'), (r"(\w+\s*)\(", r"Operators.\1("), ]: # Features # Operators field = re.sub(pattern, new, field)