MCPcopy Create free account
hub / github.com/AkaliKong/MiniOneRec / clean_text

Function clean_text

data/amazon18_data_process.py:15–27  ·  view source on GitHub ↗

Clean text by removing HTML tags and excessive whitespace

(text)

Source from the content-addressed store, hash-verified

13
14
15def clean_text(text):
16 """Clean text by removing HTML tags and excessive whitespace"""
17 if not text:
18 return ""
19 # Remove HTML tags
20 text = re.sub(r'<[^>]+>', '', str(text))
21 # Decode HTML entities
22 text = html.unescape(text)
23 # Replace quotes
24 text = text.replace("&quot;", "\"").replace("&amp;", "&")
25 # Remove excessive whitespace
26 text = re.sub(r'\s+', ' ', text)
27 return text.strip()
28
29
30def check_path(path):

Calls

no outgoing calls

Tested by

no test coverage detected