mirror of
https://github.com/langgenius/dify.git
synced 2026-09-24 23:22:26 +08:00
fix: fix remove_leading_symbols remove [ (#34832)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
autofix-ci[bot]
parent
03750b76ac
commit
d042cbc62e
@@ -19,5 +19,18 @@ def remove_leading_symbols(text: str) -> str:
|
||||
|
||||
# Match Unicode ranges for punctuation and symbols
|
||||
# FIXME this pattern is confused quick fix for #11868 maybe refactor it later
|
||||
pattern = r'^[\[\]\u2000-\u2025\u2027-\u206F\u2E00-\u2E7F\u3000-\u300F\u3011-\u303F"#$%&\'()*+,./:;<=>?@^_`~]+'
|
||||
pattern = re.compile(
|
||||
r"""
|
||||
^
|
||||
(?:
|
||||
[\u2000-\u2025] # General Punctuation: spaces, quotes, dashes
|
||||
| [\u2027-\u206F] # General Punctuation: ellipsis, underscores, etc.
|
||||
| [\u2E00-\u2E7F] # Supplemental Punctuation: medieval, ancient marks
|
||||
| [\u3000-\u300F] # CJK Punctuation: 、。〃「」『》』 (excludes 【】)
|
||||
| [\u3012-\u303F] # CJK Punctuation: 〖〗〔〕〘〙〚〛〜 etc.
|
||||
| ["#$%&'()*+,./:;<=>?@^_`~] # ASCII punctuation (excludes []【】)
|
||||
)+
|
||||
""",
|
||||
re.VERBOSE,
|
||||
)
|
||||
return re.sub(pattern, "", text)
|
||||
|
||||
Reference in New Issue
Block a user