mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-01 10:01:19 +08:00
Support feature names contain Chinese punctuation (#1003)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user