This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
importre
defclean_text(text):
"""
Remove any parenthetical segments (including Chinese parentheses) and trim whitespace.
For example, "This is a sentence(remark)" -> "This is a sentence"
Parameters:
text (str): The text to clean.
Returns:
str: The cleaned text.
"""
pattern=r'[\((][^\))]*[\))]'# Pattern to match parentheses and their contents