fix:知识库上传文档操作报异常,错误发生在 ts_vecto_util.py 文件的 replace_word 函数中:错误的原因是正则表达式模式在某个位置缺少一个右括号,使得子模式未完全结束。该提交修复了这个问题。 (#667)
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
Evan 2024-06-27 09:51:14 +08:00 committed by GitHub
parent 1af7fcb63c
commit 726ba2a8e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,7 +49,8 @@ def get_word_list(text: str):
def replace_word(word_dict, text: str):
for key in word_dict:
text = re.sub('(?<!#)' + word_dict[key] + '(?!#)', key, text)
pattern = '(?<!#)' + re.escape(word_dict[key]) + '(?!#)'
text = re.sub(pattern, key, text)
return text