File size: 852 Bytes
2005bec
 
1f5134c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2005bec
1f5134c
 
 
 
 
 
 
2005bec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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()