import re def clean_text(text: str) -> str: """ Cleans extracted resume text by: - Removing non-ASCII characters - Normalizing newlines and whitespace - Removing stray bullet points or symbols Args: text (str): Raw text input Returns: str: Cleaned and normalized text """ # Remove non-ASCII characters text = re.sub(r'[^\x00-\x7F]+', ' ', text) # Replace common bullets or symbols with newline text = re.sub(r'[\u2022•●▪■◆►▶✔➤➔➣➢➥]', '\n', text) # Collapse multiple newlines into one text = re.sub(r'\n+', '\n', text) # Collapse multiple spaces into one text = re.sub(r'[ \t]+', ' ', text) # Remove excessive blank lines text = "\n".join(line.strip() for line in text.splitlines() if line.strip()) return text.strip()