File size: 802 Bytes
84008c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# utils/info_extract.py

def extract_user_info(text: str):
    """
    Extract candidate details if provided in a single text input string.
    Example input: "Full Name: John Doe, Email Address: john@example.com"
    Returns a dictionary with expected fields.
    """
    fields = [
        "Full Name",
        "Email Address",
        "Phone Number",
        "Years of Experience",
        "Desired Position"
    ]

    info = {field: "" for field in fields}
    parts = text.split(",")

    for part in parts:
        if ":" in part:
            key, val = part.split(":", 1)
            key = key.strip()
            val = val.strip()
            for field in fields:
                if field.lower() == key.lower():
                    info[field] = val
                    break
    return info