MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / process

Function process

tools/tools.py:38–47  ·  view source on GitHub ↗

删除字符串中括号及其中的内容。 包括括号 () 和中文括号()。 :param line: 原始字符串 :return: 删除括号内容后的字符串

(line)

Source from the content-addressed store, hash-verified

36
37def remove_text_in_brackets(input_file, output_file, strong_clean_flag = False):
38 def process(line):
39 """
40 删除字符串中括号及其中的内容。
41 包括括号 () 和中文括号()。
42 :param line: 原始字符串
43 :return: 删除括号内容后的字符串
44 """
45 # 使用正则表达式匹配括号及其中的内容
46 # 匹配圆括号 () 或中文括号(),以及其中的内容
47 return re.sub(r"[\(\(][^\)\)]*[\)\)]", "", line)
48
49 def remove_non_alpha(string):
50 # 使用正则表达式删除首尾非字母字符

Callers 2

remove_text_in_bracketsFunction · 0.85
str_full_to_half_widthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected