Files
t6_mem0/embedchain/utils.py
2023-06-23 19:53:57 +05:30

11 lines
312 B
Python

import re
def clean_string(text):
text = text.replace('\n', ' ')
cleaned_text = re.sub(r'\s+', ' ', text.strip())
cleaned_text = cleaned_text.replace('\\', '')
cleaned_text = cleaned_text.replace('#', ' ')
cleaned_text = re.sub(r'([^\w\s])\1*', r'\1', cleaned_text)
return cleaned_text