DreamStream-1 commited on
Commit
6f8fec5
·
verified ·
1 Parent(s): 26fdc21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -5
app.py CHANGED
@@ -51,6 +51,37 @@ def extract_contact_info(resume_text):
51
 
52
  return name, email, contact
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  # Function to extract years of team leadership or management experience from the job description
55
  def extract_expected_years(job_description):
56
  # Use regex to extract any number of years mentioned in the job description for management or team leadership
@@ -82,6 +113,18 @@ def extract_direct_team_leadership_years(text):
82
 
83
  return total_years
84
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  # Refined Prompt Template for Gemini API (requesting detailed text about management experience)
86
  input_prompt = """
87
  Act as a sophisticated Applicant Tracking System (ATS) with expertise in evaluating resumes specifically for management and team leadership roles. Your task is to analyze the resume in relation to the job description, focusing on direct and indirect team management experience, skills, and qualifications.
@@ -100,7 +143,7 @@ Provide a detailed output that includes:
100
  - **Direct Management Experience (in years)**: Quantify and describe this experience with specific examples.
101
  - **Relevant Skills and Qualifications**: List skills and qualifications relevant to management and team leadership.
102
  - **Educational Background**: Provide a brief summary.
103
- - **Match Percentage**: Set to 70%.
104
 
105
  Input:
106
  - Resume Text: "{text}"
@@ -129,6 +172,10 @@ if uploaded_file and job_description:
129
  # Extract contact info (name, email, contact)
130
  name, email, contact = extract_contact_info(resume_text)
131
 
 
 
 
 
132
  # Extract years of experience for Direct Team Leadership and Management
133
  direct_team_leadership_years = extract_direct_team_leadership_years(resume_text)
134
  direct_management_years = direct_team_leadership_years # Reuse extraction logic for simplicity
@@ -142,8 +189,8 @@ if uploaded_file and job_description:
142
  # Clean up the response to remove unnecessary whitespace or formatting
143
  response_text_clean = response_text.strip()
144
 
145
- # Set the match percentage to 70%
146
- match_percentage = 70
147
 
148
  # Determine the Job Description Match Score
149
  job_description_match_score = "High" if match_percentage >= 80 else "Moderate" if match_percentage >= 50 else "Low"
@@ -155,8 +202,8 @@ if uploaded_file and job_description:
155
  'Contact': [contact],
156
  'Direct_Team_Leadership_Experience_Years': [direct_team_leadership_years],
157
  'Direct_Management_Experience_Years': [direct_management_years],
158
- 'Relevant_Skills_and_Qualifications': ["Placeholder for skills"], # To be updated with real data
159
- 'Educational_Background': ["Placeholder for education"], # To be updated with real data
160
  'Model_Response': [response_text_clean],
161
  'Match_Percentage': [match_percentage],
162
  'Job_Description_Match_Score': [job_description_match_score]
 
51
 
52
  return name, email, contact
53
 
54
+ # Function to extract relevant skills from the resume text
55
+ def extract_relevant_skills(resume_text):
56
+ # Look for sections related to skills/competencies
57
+ skills_section_keywords = ["skills", "technical skills", "competencies", "technologies", "tools"]
58
+ skills = []
59
+
60
+ for keyword in skills_section_keywords:
61
+ pattern = r"(?i)(%s):?\s*([^\n]+)" % re.escape(keyword)
62
+ matches = re.findall(pattern, resume_text)
63
+ for match in matches:
64
+ skills += match[1].split(",") # Split skills by comma
65
+
66
+ # Clean up and remove empty strings or leading/trailing spaces
67
+ skills = [skill.strip() for skill in skills if skill.strip()]
68
+
69
+ return skills
70
+
71
+ # Function to extract educational background from the resume text
72
+ def extract_educational_background(resume_text):
73
+ # Look for common phrases related to education
74
+ education_keywords = ["bachelor", "master", "degree", "university", "college", "diploma"]
75
+ education = []
76
+
77
+ for keyword in education_keywords:
78
+ pattern = r"(?i)(%s)[^,]*[\.,;]" % re.escape(keyword)
79
+ matches = re.findall(pattern, resume_text)
80
+ for match in matches:
81
+ education.append(match.strip())
82
+
83
+ return education
84
+
85
  # Function to extract years of team leadership or management experience from the job description
86
  def extract_expected_years(job_description):
87
  # Use regex to extract any number of years mentioned in the job description for management or team leadership
 
113
 
114
  return total_years
115
 
116
+ # Function to calculate match percentage based on experience
117
+ def calculate_match_percentage(direct_team_leadership_years, direct_management_years):
118
+ # Give more weight to leadership and management experience
119
+ if direct_team_leadership_years >= 2 and direct_management_years >= 3:
120
+ return 80 # High match
121
+ elif direct_team_leadership_years >= 1 and direct_management_years >= 2:
122
+ return 70 # Moderate match
123
+ elif direct_team_leadership_years > 0 or direct_management_years > 0:
124
+ return 50 # Low to moderate match
125
+ else:
126
+ return 30 # Very low match
127
+
128
  # Refined Prompt Template for Gemini API (requesting detailed text about management experience)
129
  input_prompt = """
130
  Act as a sophisticated Applicant Tracking System (ATS) with expertise in evaluating resumes specifically for management and team leadership roles. Your task is to analyze the resume in relation to the job description, focusing on direct and indirect team management experience, skills, and qualifications.
 
143
  - **Direct Management Experience (in years)**: Quantify and describe this experience with specific examples.
144
  - **Relevant Skills and Qualifications**: List skills and qualifications relevant to management and team leadership.
145
  - **Educational Background**: Provide a brief summary.
146
+ - **Match Percentage**: Calculate the match percentage (between 30%-100%) based on leadership and management experience.
147
 
148
  Input:
149
  - Resume Text: "{text}"
 
172
  # Extract contact info (name, email, contact)
173
  name, email, contact = extract_contact_info(resume_text)
174
 
175
+ # Extract relevant skills and educational background
176
+ relevant_skills = extract_relevant_skills(resume_text)
177
+ educational_background = extract_educational_background(resume_text)
178
+
179
  # Extract years of experience for Direct Team Leadership and Management
180
  direct_team_leadership_years = extract_direct_team_leadership_years(resume_text)
181
  direct_management_years = direct_team_leadership_years # Reuse extraction logic for simplicity
 
189
  # Clean up the response to remove unnecessary whitespace or formatting
190
  response_text_clean = response_text.strip()
191
 
192
+ # Set the match percentage based on extracted data
193
+ match_percentage = calculate_match_percentage(direct_team_leadership_years, direct_management_years)
194
 
195
  # Determine the Job Description Match Score
196
  job_description_match_score = "High" if match_percentage >= 80 else "Moderate" if match_percentage >= 50 else "Low"
 
202
  'Contact': [contact],
203
  'Direct_Team_Leadership_Experience_Years': [direct_team_leadership_years],
204
  'Direct_Management_Experience_Years': [direct_management_years],
205
+ 'Relevant_Skills_and_Qualifications': [", ".join(relevant_skills)],
206
+ 'Educational_Background': [", ".join(educational_background)],
207
  'Model_Response': [response_text_clean],
208
  'Match_Percentage': [match_percentage],
209
  'Job_Description_Match_Score': [job_description_match_score]