File size: 3,459 Bytes
658a9ba
5f7f5f1
40cbcc6
63fc548
 
 
 
40cbcc6
658a9ba
5f7f5f1
63fc548
 
 
 
93a8810
5f7f5f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658a9ba
63fc548
 
 
 
 
93a8810
5f7f5f1
 
658a9ba
5f7f5f1
 
93a8810
63fc548
5f7f5f1
 
 
 
 
934a3a3
5f7f5f1
 
 
 
 
934a3a3
5f7f5f1
 
658a9ba
5f7f5f1
 
cca845e
e5a1d27
b3b0f5d
 
5f7f5f1
b3b0f5d
 
 
 
 
 
 
 
8104f27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import pandas as pd

import pandas as pd
import os

CSV_FOLDER = os.path.join(os.path.dirname(__file__), "..", "csvs")

def load_csv(filename):
    path = os.path.join(CSV_FOLDER, filename)
    df = pd.read_csv(path)
    df.columns = df.columns.str.strip().str.lower()  # Normalize headers
    return df


def extract_field_from_text(text):
    # Dummy implementation: extract the main field keyword from the parsed CV text
    # You should replace this with your actual field extraction logic or pass field directly
    keywords = [
        "accounting", "agriculture", "architecture", "artificial intelligence", "biology", 
        "business analysis", "chemistry", "civil engineering", "data science", "dentistry",
        "electrical engineering", "finance", "graphic design", "healthcare", "hospitality",
        "information technology", "journalism", "law", "marketing", "mechanical engineering",
        "nursing", "pharmacy", "psychology", "quality assurance", "robotics", "sales",
        "software development", "statistics", "teaching", "ux design", "veterinary",
        "web development", "x-ray technology", "youth counseling", "zoology"
    ]
    text_lower = text.lower()
    for kw in keywords:
        if kw in text_lower:
            return kw
    return "general"  # fallback

def match_field(field, df):
    field = field.lower()
    if "field" not in df.columns or "suggestion" not in df.columns:
        raise KeyError("CSV file must have 'field' and 'suggestion' columns.")
    match = df[df['field'].str.lower().str.contains(field, na=False)]
    return match

def get_certification_suggestions(parsed_text):
    field = extract_field_from_text(parsed_text)
    df = load_csv("certifications.csv")
    matched = match_field(field, df)
    return matched['suggestion'].tolist()


def get_higher_education_suggestions(parsed_text):
    field = extract_field_from_text(parsed_text)
    df = load_csv("higher_education.csv")
    matched = match_field(field, df)
    return matched['suggestion'].tolist()

def get_visa_recommendations(parsed_text):
    field = extract_field_from_text(parsed_text)
    df = load_csv("visa_recommendations.csv")
    matched = match_field(field, df)
    return matched['suggestion'].tolist()

def get_career_advice(parsed_text):
    field = extract_field_from_text(parsed_text)
    df = load_csv("career_advice.csv")
    matched = match_field(field, df)
    return matched['suggestion'].tolist()

def get_job_listings(cv_text):
    df = load_csv("jobs.csv")
    field = identify_field(cv_text)
    matched = match_field(field, df)
    
    # Handle either 'listing' or 'suggestion' key
    for col in ['listing', 'suggestion']:
        if col in matched.columns:
            return matched[col].dropna().tolist()
    
    raise KeyError("CSV file must have either 'listing' or 'suggestion' column.")

def identify_field(cv_text):
    # A basic mock-up: you should replace this with actual NLP/ML logic
    lower_text = cv_text.lower()
    if "python" in lower_text or "software" in lower_text or "developer" in lower_text:
        return "Software Development"
    elif "accounting" in lower_text or "finance" in lower_text:
        return "Accounting"
    elif "nurse" in lower_text or "clinical" in lower_text:
        return "Nursing"
    elif "biology" in lower_text:
        return "Biology"
    elif "marketing" in lower_text:
        return "Marketing"
    else:
        return "General"