Spaces:
Restarting
on
L4
Restarting
on
L4
root
commited on
Commit
·
72d33a9
1
Parent(s):
eaa3094
ss
Browse files- app.py +384 -570
- requirements.txt +18 -20
app.py
CHANGED
@@ -1,89 +1,131 @@
|
|
1 |
import streamlit as st
|
2 |
import pdfplumber
|
3 |
-
import io
|
4 |
-
import spacy
|
5 |
-
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
6 |
-
import subprocess
|
7 |
-
import sys
|
8 |
-
import torch
|
9 |
import re
|
10 |
import pandas as pd
|
11 |
-
import
|
|
|
|
|
12 |
import plotly.express as px
|
13 |
import plotly.graph_objects as go
|
14 |
-
|
15 |
-
import dateparser
|
16 |
-
from sentence_transformers import SentenceTransformer
|
17 |
-
import nltk
|
18 |
-
from nltk.tokenize import word_tokenize
|
19 |
-
from nltk.corpus import stopwords
|
20 |
-
from sklearn.metrics.pairwise import cosine_similarity
|
21 |
-
import faiss
|
22 |
-
import requests
|
23 |
-
from bs4 import BeautifulSoup
|
24 |
-
import networkx as nx
|
25 |
-
import Levenshtein
|
26 |
-
import json
|
27 |
-
import matplotlib.pyplot as plt
|
28 |
-
from io import BytesIO
|
29 |
-
import base64
|
30 |
-
from sentence_transformers import util
|
31 |
-
|
32 |
-
# Download NLTK resources
|
33 |
-
@st.cache_resource
|
34 |
-
def download_nltk_resources():
|
35 |
-
nltk.download('punkt')
|
36 |
-
nltk.download('stopwords')
|
37 |
-
nltk.download('wordnet')
|
38 |
-
nltk.download('averaged_perceptron_tagger')
|
39 |
-
|
40 |
-
download_nltk_resources()
|
41 |
|
|
|
42 |
st.set_page_config(
|
43 |
page_title="Resume Screener & Skill Extractor",
|
44 |
page_icon="📄",
|
45 |
layout="wide"
|
46 |
)
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
try:
|
52 |
-
|
53 |
-
except
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
# Load
|
59 |
@st.cache_resource
|
60 |
def load_models():
|
61 |
-
|
62 |
-
nlp = download_spacy_model()
|
63 |
|
64 |
-
# Load
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
# Load
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
"
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
qwen_tokenizer = None
|
79 |
-
qwen_model = None
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
# Job descriptions
|
87 |
job_descriptions = {
|
88 |
"Software Engineer": {
|
89 |
"skills": ["python", "java", "javascript", "sql", "algorithms", "data structures",
|
@@ -120,137 +162,272 @@ job_descriptions = {
|
|
120 |
"Mid-level": "3-5 years of experience, model development, feature engineering",
|
121 |
"Senior": "6+ years of experience, advanced ML techniques, research experience"
|
122 |
}
|
123 |
-
},
|
124 |
-
"Product Manager": {
|
125 |
-
"skills": ["product strategy", "roadmap planning", "user stories", "agile", "market research",
|
126 |
-
"stakeholder management", "analytics", "user experience", "a/b testing", "prioritization"],
|
127 |
-
"description": "Seeking product managers who can drive product vision, strategy, and execution.",
|
128 |
-
"must_have": ["product strategy", "roadmap planning", "stakeholder management"],
|
129 |
-
"nice_to_have": ["agile", "analytics", "a/b testing"],
|
130 |
-
"seniority_levels": {
|
131 |
-
"Junior": "0-2 years of experience, assisting with feature definition and user stories",
|
132 |
-
"Mid-level": "3-5 years of experience, owning products/features, market research",
|
133 |
-
"Senior": "6+ years of experience, defining product vision, managing teams, strategic planning"
|
134 |
-
}
|
135 |
-
},
|
136 |
-
"DevOps Engineer": {
|
137 |
-
"skills": ["linux", "aws", "docker", "kubernetes", "ci/cd", "terraform",
|
138 |
-
"ansible", "monitoring", "scripting", "automation", "security"],
|
139 |
-
"description": "Looking for DevOps engineers to build and maintain infrastructure and deployment pipelines.",
|
140 |
-
"must_have": ["linux", "docker", "ci/cd"],
|
141 |
-
"nice_to_have": ["kubernetes", "terraform", "aws"],
|
142 |
-
"seniority_levels": {
|
143 |
-
"Junior": "0-2 years of experience, basic system administration, scripting",
|
144 |
-
"Mid-level": "3-5 years of experience, container orchestration, infrastructure as code",
|
145 |
-
"Senior": "6+ years of experience, architecture design, security, team leadership"
|
146 |
-
}
|
147 |
}
|
148 |
}
|
149 |
|
|
|
150 |
def extract_text_from_pdf(pdf_file):
|
|
|
151 |
text = ""
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
155 |
return text
|
156 |
|
157 |
-
def
|
158 |
-
|
159 |
-
doc = nlp(text.lower())
|
160 |
found_skills = []
|
161 |
required_skills = job_descriptions[job_title]["skills"]
|
162 |
|
|
|
163 |
for skill in required_skills:
|
164 |
-
if skill in text.lower():
|
165 |
found_skills.append(skill)
|
166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
# Generate summary
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
173 |
|
174 |
-
# Extract experience
|
175 |
experiences = extract_experience(text)
|
176 |
|
177 |
# Calculate semantic match score
|
178 |
-
match_score =
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
-
#
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
|
|
188 |
|
189 |
-
#
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
#
|
193 |
-
career_prediction =
|
194 |
|
195 |
return {
|
196 |
'found_skills': found_skills,
|
197 |
-
'
|
|
|
198 |
'experiences': experiences,
|
199 |
'match_score': match_score,
|
200 |
'seniority': seniority,
|
201 |
-
'years_experience':
|
202 |
-
'skill_levels': skill_levels,
|
203 |
'inconsistencies': inconsistencies,
|
204 |
-
'company_verification': company_verification,
|
205 |
'career_prediction': career_prediction
|
206 |
}
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
def generate_career_advice(resume_text, job_title, found_skills, missing_skills):
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
# Create a prompt for the model
|
213 |
-
prompt = f"""
|
214 |
-
You are a professional career advisor. Based on the resume and the target job position,
|
215 |
-
provide personalized advice on skills to develop and suggest projects that would help the candidate
|
216 |
-
become a better fit for the position.
|
217 |
|
218 |
-
|
219 |
|
220 |
-
|
221 |
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
-
|
225 |
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
3. Resources for learning (courses, books, websites)
|
232 |
"""
|
|
|
|
|
233 |
|
234 |
-
|
235 |
-
|
236 |
-
inputs = qwen_tokenizer(prompt, return_tensors="pt").to(qwen_model.device)
|
237 |
-
with torch.no_grad():
|
238 |
-
outputs = qwen_model.generate(
|
239 |
-
**inputs,
|
240 |
-
max_new_tokens=1024,
|
241 |
-
temperature=0.7,
|
242 |
-
top_p=0.9,
|
243 |
-
do_sample=True
|
244 |
-
)
|
245 |
-
advice = qwen_tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
246 |
-
return advice
|
247 |
-
except Exception as e:
|
248 |
-
return f"Failed to generate career advice: {str(e)}"
|
249 |
|
250 |
-
#
|
251 |
-
|
252 |
|
253 |
-
#
|
254 |
st.markdown("""
|
255 |
This app helps recruiters analyze resumes by:
|
256 |
- Extracting relevant skills for specific job positions
|
@@ -283,38 +460,36 @@ if uploaded_file and job_title:
|
|
283 |
text = extract_text_from_pdf(uploaded_file)
|
284 |
|
285 |
# Analyze resume
|
286 |
-
|
287 |
|
288 |
# Calculate missing skills
|
289 |
missing_skills = [skill for skill in job_descriptions[job_title]["skills"]
|
290 |
-
|
291 |
|
292 |
# Display results in tabs
|
293 |
-
tab1, tab2, tab3, tab4
|
294 |
"📊 Skills Match",
|
295 |
"📝 Resume Summary",
|
296 |
"🎯 Skills Gap",
|
297 |
-
"👨💼 Career Path",
|
298 |
-
"🔍 Authentication",
|
299 |
"🚀 Career Advice"
|
300 |
])
|
301 |
|
302 |
with tab1:
|
303 |
-
#
|
304 |
col1, col2 = st.columns(2)
|
305 |
|
306 |
with col1:
|
307 |
# Display matched skills
|
308 |
st.subheader("🎯 Matched Skills")
|
309 |
-
if
|
310 |
-
for skill in
|
311 |
# Show skill with proficiency level
|
312 |
-
level =
|
313 |
level_emoji = "🟢" if level == 'advanced' else "🟡" if level == 'intermediate' else "🟠"
|
314 |
st.success(f"{level_emoji} {skill.title()} ({level.title()})")
|
315 |
|
316 |
# Calculate match percentage
|
317 |
-
match_percentage = len(
|
318 |
st.metric("Skills Match", f"{match_percentage:.1f}%")
|
319 |
else:
|
320 |
st.warning("No direct skill matches found.")
|
@@ -322,11 +497,11 @@ if uploaded_file and job_title:
|
|
322 |
with col2:
|
323 |
# Display semantic match score
|
324 |
st.subheader("💡 Semantic Match")
|
325 |
-
st.metric("Overall Match Score", f"{
|
326 |
|
327 |
# Display must-have skills match
|
328 |
must_have_skills = job_descriptions[job_title]["must_have"]
|
329 |
-
must_have_count = sum(1 for skill in must_have_skills if skill in
|
330 |
must_have_percentage = (must_have_count / len(must_have_skills)) * 100
|
331 |
|
332 |
st.write("Must-have skills:")
|
@@ -335,20 +510,20 @@ if uploaded_file and job_title:
|
|
335 |
|
336 |
# Professional level assessment
|
337 |
st.subheader("🧠 Seniority Assessment")
|
338 |
-
st.info(f"**{
|
339 |
-
st.write(job_descriptions[job_title]["seniority_levels"][
|
340 |
|
341 |
with tab2:
|
342 |
# Display resume summary
|
343 |
st.subheader("📝 Resume Summary")
|
344 |
-
st.write(
|
345 |
|
346 |
# Display experience timeline
|
347 |
st.subheader("⏳ Experience Timeline")
|
348 |
-
if
|
349 |
# Convert experiences to dataframe for display
|
350 |
exp_data = []
|
351 |
-
for exp in
|
352 |
if 'start_date' in exp and 'end_date' in exp:
|
353 |
exp_data.append({
|
354 |
'Company': exp['company'],
|
@@ -369,33 +544,36 @@ if uploaded_file and job_title:
|
|
369 |
st.dataframe(exp_df)
|
370 |
|
371 |
# Create a timeline visualization if dates are available
|
372 |
-
timeline_data = [exp for exp in
|
373 |
-
if timeline_data:
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
|
|
|
|
|
|
399 |
else:
|
400 |
st.warning("No work experience data could be extracted.")
|
401 |
|
@@ -420,7 +598,7 @@ if uploaded_file and job_title:
|
|
420 |
|
421 |
# Show must-have skills that are missing
|
422 |
missing_must_have = [skill for skill in job_descriptions[job_title]["must_have"]
|
423 |
-
if skill not in
|
424 |
|
425 |
if missing_must_have:
|
426 |
st.error("**Critical Skills Missing:**")
|
@@ -433,7 +611,7 @@ if uploaded_file and job_title:
|
|
433 |
|
434 |
# Show nice-to-have skills gap
|
435 |
missing_nice_to_have = [skill for skill in job_descriptions[job_title]["nice_to_have"]
|
436 |
-
if skill not in
|
437 |
|
438 |
if missing_nice_to_have:
|
439 |
st.warning("**Nice-to-Have Skills Missing:**")
|
@@ -441,388 +619,24 @@ if uploaded_file and job_title:
|
|
441 |
st.write(f"- {skill.title()}")
|
442 |
else:
|
443 |
st.success("Candidate has all the nice-to-have skills!")
|
444 |
-
|
445 |
-
with tab4:
|
446 |
-
# Display career path insights
|
447 |
-
st.subheader("👨💼 Career Trajectory")
|
448 |
-
|
449 |
-
# Show career prediction
|
450 |
-
st.info(resume_data['career_prediction'])
|
451 |
-
|
452 |
-
# Show experience trends
|
453 |
-
st.subheader("📈 Experience Analysis")
|
454 |
-
|
455 |
-
# Check for job hopping
|
456 |
-
if len(resume_data['experiences']) >= 3:
|
457 |
-
# Calculate average job duration
|
458 |
-
durations = [exp.get('duration_months', 0) for exp in resume_data['experiences']
|
459 |
-
if 'duration_months' in exp]
|
460 |
-
|
461 |
-
if durations:
|
462 |
-
avg_duration = sum(durations) / len(durations)
|
463 |
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
st.warning(f"⚠️ **Moderate Job Hopping**: Average job duration is {avg_duration:.1f} months")
|
468 |
-
else:
|
469 |
-
st.success(f"✅ **Stable Employment**: Average job duration is {avg_duration:.1f} months")
|
470 |
-
|
471 |
-
# Show inconsistencies if any
|
472 |
-
if resume_data['inconsistencies']:
|
473 |
-
st.subheader("⚠️ Timeline Inconsistencies")
|
474 |
-
for issue in resume_data['inconsistencies']:
|
475 |
-
if issue['type'] == 'overlap':
|
476 |
-
st.warning(issue['description'])
|
477 |
-
elif issue['type'] == 'gap':
|
478 |
-
st.info(issue['description'])
|
479 |
-
|
480 |
-
with tab5:
|
481 |
-
# Display authentication signals
|
482 |
-
st.subheader("🔍 Resume Authentication")
|
483 |
-
|
484 |
-
# Company verification results
|
485 |
-
st.write("**Company Verification Results:**")
|
486 |
-
|
487 |
-
if resume_data['company_verification']:
|
488 |
-
# Count suspicious companies
|
489 |
-
suspicious_count = sum(1 for v in resume_data['company_verification']
|
490 |
-
if v['status'] == 'suspicious')
|
491 |
-
|
492 |
-
if suspicious_count == 0:
|
493 |
-
st.success("✅ All companies mentioned in the resume passed basic verification")
|
494 |
-
else:
|
495 |
-
st.warning(f"⚠️ {suspicious_count} companies require further verification")
|
496 |
-
|
497 |
-
# Display verification details
|
498 |
-
verification_data = [{
|
499 |
-
'Company': v['company'],
|
500 |
-
'Status': v['status'].title(),
|
501 |
-
'Notes': v['reason']
|
502 |
-
} for v in resume_data['company_verification']]
|
503 |
-
|
504 |
-
st.dataframe(pd.DataFrame(verification_data))
|
505 |
-
else:
|
506 |
-
st.info("No company information found for verification.")
|
507 |
-
|
508 |
-
# Timeline consistency check
|
509 |
-
st.write("**Timeline Consistency Check:**")
|
510 |
-
|
511 |
-
if not resume_data['inconsistencies']:
|
512 |
-
st.success("✅ No timeline inconsistencies detected")
|
513 |
-
else:
|
514 |
-
st.warning(f"⚠️ {len(resume_data['inconsistencies'])} timeline inconsistencies found")
|
515 |
-
for issue in resume_data['inconsistencies']:
|
516 |
-
st.write(f"- {issue['description']}")
|
517 |
|
518 |
-
with
|
519 |
# Display career advice
|
520 |
st.subheader("🚀 Career Advice and Project Recommendations")
|
521 |
|
522 |
if st.button("Generate Career Advice"):
|
523 |
with st.spinner("Generating personalized career advice..."):
|
524 |
-
advice = generate_career_advice(text, job_title,
|
525 |
st.markdown(advice)
|
526 |
|
527 |
except Exception as e:
|
528 |
st.error(f"An error occurred while processing the resume: {str(e)}")
|
|
|
529 |
|
530 |
# Add footer
|
531 |
st.markdown("---")
|
532 |
-
st.markdown("Made with ❤️ using Streamlit and Hugging Face")
|
533 |
-
|
534 |
-
# Semantic matching between resume and job description
|
535 |
-
def semantic_matching(resume_text, job_title):
|
536 |
-
job_desc = job_descriptions[job_title]["description"]
|
537 |
-
|
538 |
-
# Encode texts using sentence transformers
|
539 |
-
resume_embedding = sentence_model.encode(resume_text, convert_to_tensor=True)
|
540 |
-
job_embedding = sentence_model.encode(job_desc, convert_to_tensor=True)
|
541 |
-
|
542 |
-
# Calculate cosine similarity
|
543 |
-
cos_sim = cosine_similarity(
|
544 |
-
resume_embedding.cpu().numpy().reshape(1, -1),
|
545 |
-
job_embedding.cpu().numpy().reshape(1, -1)
|
546 |
-
)[0][0]
|
547 |
-
|
548 |
-
return cos_sim * 100 # Convert to percentage
|
549 |
-
|
550 |
-
# Extract experience timeline from resume
|
551 |
-
def extract_experience(text):
|
552 |
-
# Pattern to find work experience entries
|
553 |
-
# Look for patterns like "Company Name | Role | Jan 2020 - Present"
|
554 |
-
exp_pattern = r"(?i)(.*?(?:inc|llc|ltd|company|corp|corporation|group)?)\s*(?:[|•-]\s*)?(.*?)(?:[|•-]\s*)((?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[\w\s,]*\d{4}\s*(?:-|to|–)\s*(?:(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[\w\s,]*\d{4}|present))"
|
555 |
-
|
556 |
-
experiences = []
|
557 |
-
for match in re.finditer(exp_pattern, text, re.IGNORECASE):
|
558 |
-
company = match.group(1).strip()
|
559 |
-
role = match.group(2).strip()
|
560 |
-
duration = match.group(3).strip()
|
561 |
-
|
562 |
-
# Parse dates
|
563 |
-
try:
|
564 |
-
date_range = duration.split('-') if '-' in duration else duration.split('to') if 'to' in duration else duration.split('–')
|
565 |
-
start_date = dateparser.parse(date_range[0].strip())
|
566 |
-
|
567 |
-
if 'present' in date_range[1].lower():
|
568 |
-
end_date = datetime.now()
|
569 |
-
else:
|
570 |
-
end_date = dateparser.parse(date_range[1].strip())
|
571 |
-
|
572 |
-
if start_date and end_date:
|
573 |
-
# Calculate duration in months
|
574 |
-
months = (end_date.year - start_date.year) * 12 + (end_date.month - start_date.month)
|
575 |
-
|
576 |
-
experiences.append({
|
577 |
-
'company': company,
|
578 |
-
'role': role,
|
579 |
-
'start_date': start_date,
|
580 |
-
'end_date': end_date,
|
581 |
-
'duration_months': months
|
582 |
-
})
|
583 |
-
except:
|
584 |
-
# If date parsing fails, still include the experience without dates
|
585 |
-
experiences.append({
|
586 |
-
'company': company,
|
587 |
-
'role': role,
|
588 |
-
'duration': duration
|
589 |
-
})
|
590 |
-
|
591 |
-
return experiences
|
592 |
-
|
593 |
-
# Estimate seniority based on experience and skills
|
594 |
-
def estimate_seniority(experiences, found_skills, job_title):
|
595 |
-
# Calculate total experience in years
|
596 |
-
total_months = sum(exp.get('duration_months', 0) for exp in experiences if 'duration_months' in exp)
|
597 |
-
total_years = total_months / 12
|
598 |
-
|
599 |
-
# Count leadership keywords in roles
|
600 |
-
leadership_keywords = ['lead', 'senior', 'manager', 'head', 'principal', 'architect', 'director']
|
601 |
-
leadership_count = 0
|
602 |
-
|
603 |
-
for exp in experiences:
|
604 |
-
role = exp.get('role', '').lower()
|
605 |
-
for keyword in leadership_keywords:
|
606 |
-
if keyword in role:
|
607 |
-
leadership_count += 1
|
608 |
-
break
|
609 |
-
|
610 |
-
# Calculate skill match percentage for must-have skills
|
611 |
-
must_have_skills = job_descriptions[job_title]["must_have"]
|
612 |
-
must_have_count = sum(1 for skill in must_have_skills if skill in [s.lower() for s in found_skills])
|
613 |
-
must_have_percentage = (must_have_count / len(must_have_skills)) * 100 if must_have_skills else 0
|
614 |
-
|
615 |
-
# Determine seniority level
|
616 |
-
if total_years < 3:
|
617 |
-
seniority = "Junior"
|
618 |
-
elif total_years < 6:
|
619 |
-
seniority = "Mid-level"
|
620 |
-
else:
|
621 |
-
seniority = "Senior"
|
622 |
-
|
623 |
-
# Adjust based on leadership roles and skill match
|
624 |
-
if leadership_count >= 2 and seniority != "Senior":
|
625 |
-
seniority = "Senior" if total_years >= 4 else seniority
|
626 |
-
if must_have_percentage < 50 and seniority == "Senior":
|
627 |
-
seniority = "Mid-level"
|
628 |
-
|
629 |
-
return seniority, total_years, leadership_count, must_have_percentage
|
630 |
-
|
631 |
-
# Check for timeline inconsistencies
|
632 |
-
def check_timeline_inconsistencies(experiences):
|
633 |
-
if not experiences:
|
634 |
-
return []
|
635 |
-
|
636 |
-
inconsistencies = []
|
637 |
-
sorted_experiences = sorted(
|
638 |
-
[exp for exp in experiences if 'start_date' in exp and 'end_date' in exp],
|
639 |
-
key=lambda x: x['start_date']
|
640 |
-
)
|
641 |
-
|
642 |
-
for i in range(len(sorted_experiences) - 1):
|
643 |
-
current = sorted_experiences[i]
|
644 |
-
next_exp = sorted_experiences[i + 1]
|
645 |
-
|
646 |
-
# Check for overlapping full-time roles
|
647 |
-
if current['end_date'] > next_exp['start_date']:
|
648 |
-
overlap_months = (current['end_date'].year - next_exp['start_date'].year) * 12 + \
|
649 |
-
(current['end_date'].month - next_exp['start_date'].month)
|
650 |
-
|
651 |
-
if overlap_months > 1: # Allow 1 month overlap for transitions
|
652 |
-
inconsistencies.append({
|
653 |
-
'type': 'overlap',
|
654 |
-
'description': f"Overlapping roles: {current['company']} and {next_exp['company']} " +
|
655 |
-
f"overlap by {overlap_months} months"
|
656 |
-
})
|
657 |
-
|
658 |
-
# Check for gaps in employment
|
659 |
-
for i in range(len(sorted_experiences) - 1):
|
660 |
-
current = sorted_experiences[i]
|
661 |
-
next_exp = sorted_experiences[i + 1]
|
662 |
-
|
663 |
-
gap_months = (next_exp['start_date'].year - current['end_date'].year) * 12 + \
|
664 |
-
(next_exp['start_date'].month - current['end_date'].month)
|
665 |
-
|
666 |
-
if gap_months > 3: # Flag gaps longer than 3 months
|
667 |
-
inconsistencies.append({
|
668 |
-
'type': 'gap',
|
669 |
-
'description': f"Employment gap of {gap_months} months between " +
|
670 |
-
f"{current['company']} and {next_exp['company']}"
|
671 |
-
})
|
672 |
-
|
673 |
-
return inconsistencies
|
674 |
-
|
675 |
-
# Verify company existence (simplified version)
|
676 |
-
def verify_companies(experiences):
|
677 |
-
verification_results = []
|
678 |
-
|
679 |
-
for exp in experiences:
|
680 |
-
company = exp.get('company', '')
|
681 |
-
if not company:
|
682 |
-
continue
|
683 |
-
|
684 |
-
# Simple heuristic - companies less than 3 characters are suspicious
|
685 |
-
if len(company) < 3:
|
686 |
-
verification_results.append({
|
687 |
-
'company': company,
|
688 |
-
'status': 'suspicious',
|
689 |
-
'reason': 'Company name too short'
|
690 |
-
})
|
691 |
-
continue
|
692 |
-
|
693 |
-
# Check if company matches common fake patterns
|
694 |
-
fake_patterns = ['abc company', 'xyz corp', 'my company', 'personal project']
|
695 |
-
if any(pattern in company.lower() for pattern in fake_patterns):
|
696 |
-
verification_results.append({
|
697 |
-
'company': company,
|
698 |
-
'status': 'suspicious',
|
699 |
-
'reason': 'Matches pattern of fake company names'
|
700 |
-
})
|
701 |
-
continue
|
702 |
-
|
703 |
-
# In a real implementation, you'd call an API to check if the company exists
|
704 |
-
# For this demo, we'll just mark all others as verified
|
705 |
-
verification_results.append({
|
706 |
-
'company': company,
|
707 |
-
'status': 'verified',
|
708 |
-
'reason': 'Passed basic verification checks'
|
709 |
-
})
|
710 |
-
|
711 |
-
return verification_results
|
712 |
-
|
713 |
-
# Extract skill levels from text
|
714 |
-
def extract_skill_levels(text, skills):
|
715 |
-
skill_levels = {}
|
716 |
-
proficiency_indicators = {
|
717 |
-
'basic': ['basic', 'familiar', 'beginner', 'fundamentals', 'exposure'],
|
718 |
-
'intermediate': ['intermediate', 'proficient', 'experienced', 'competent', 'skilled'],
|
719 |
-
'advanced': ['advanced', 'expert', 'mastery', 'specialist', 'lead', 'senior']
|
720 |
-
}
|
721 |
-
|
722 |
-
for skill in skills:
|
723 |
-
# Look for sentences containing the skill
|
724 |
-
sentences = re.findall(r'[^.!?]*%s[^.!?]*[.!?]' % re.escape(skill), text.lower())
|
725 |
-
|
726 |
-
# Default level
|
727 |
-
level = 'intermediate'
|
728 |
-
|
729 |
-
# Check for years of experience indicators
|
730 |
-
years_pattern = re.compile(r'(\d+)\s*(?:\+)?\s*years?(?:\s+of)?\s+(?:experience|exp)?\s+(?:with|in|using)?\s+%s' % re.escape(skill), re.IGNORECASE)
|
731 |
-
for sentence in sentences:
|
732 |
-
years_match = years_pattern.search(sentence)
|
733 |
-
if years_match:
|
734 |
-
years = int(years_match.group(1))
|
735 |
-
if years < 2:
|
736 |
-
level = 'basic'
|
737 |
-
elif years < 5:
|
738 |
-
level = 'intermediate'
|
739 |
-
else:
|
740 |
-
level = 'advanced'
|
741 |
-
break
|
742 |
-
|
743 |
-
# Check for proficiency indicators
|
744 |
-
if level == 'intermediate': # Only override if not already set by years
|
745 |
-
for level_name, indicators in proficiency_indicators.items():
|
746 |
-
for indicator in indicators:
|
747 |
-
pattern = re.compile(r'%s\s+(?:\w+\s+){0,3}%s' % (indicator, re.escape(skill)), re.IGNORECASE)
|
748 |
-
if any(pattern.search(sentence) for sentence in sentences):
|
749 |
-
level = level_name
|
750 |
-
break
|
751 |
-
if level != 'intermediate':
|
752 |
-
break
|
753 |
-
|
754 |
-
skill_levels[skill] = level
|
755 |
-
|
756 |
-
return skill_levels
|
757 |
-
|
758 |
-
# Generate career trajectory prediction
|
759 |
-
def predict_career_trajectory(experiences, seniority, job_title):
|
760 |
-
if not experiences:
|
761 |
-
return "Unable to predict trajectory due to insufficient experience data."
|
762 |
-
|
763 |
-
# Extract roles in chronological order
|
764 |
-
roles = [exp.get('role', '').lower() for exp in experiences if 'role' in exp]
|
765 |
-
|
766 |
-
# If less than 2 roles, not enough data for prediction
|
767 |
-
if len(roles) < 2:
|
768 |
-
if seniority == "Junior":
|
769 |
-
next_role = "Mid-level " + job_title
|
770 |
-
elif seniority == "Mid-level":
|
771 |
-
next_role = "Senior " + job_title
|
772 |
-
else: # Senior
|
773 |
-
leadership_titles = {
|
774 |
-
"Software Engineer": "Technical Lead or Engineering Manager",
|
775 |
-
"Data Scientist": "Lead Data Scientist or Data Science Manager",
|
776 |
-
"Interaction Designer": "Design Lead or UX Director",
|
777 |
-
"Product Manager": "Senior Product Manager or Director of Product",
|
778 |
-
"DevOps Engineer": "DevOps Lead or Infrastructure Architect"
|
779 |
-
}
|
780 |
-
next_role = leadership_titles.get(job_title, f"Director of {job_title}")
|
781 |
-
|
782 |
-
return f"Based on current seniority level, the next logical role could be: {next_role}"
|
783 |
-
|
784 |
-
# Check for upward mobility patterns
|
785 |
-
progression_indicators = ['junior', 'senior', 'lead', 'manager', 'director', 'vp', 'head', 'chief']
|
786 |
-
current_level = -1
|
787 |
-
|
788 |
-
for role in roles:
|
789 |
-
for i, indicator in enumerate(progression_indicators):
|
790 |
-
if indicator in role:
|
791 |
-
if i > current_level:
|
792 |
-
current_level = i
|
793 |
-
|
794 |
-
# Predict next role based on current level
|
795 |
-
if current_level < len(progression_indicators) - 1:
|
796 |
-
next_level = progression_indicators[current_level + 1]
|
797 |
-
|
798 |
-
# Map to specific job titles
|
799 |
-
if next_level == 'senior' and 'senior' not in roles[-1].lower():
|
800 |
-
next_role = f"Senior {job_title}"
|
801 |
-
elif next_level == 'lead':
|
802 |
-
next_role = f"{job_title} Lead"
|
803 |
-
elif next_level == 'manager':
|
804 |
-
if job_title == "Software Engineer":
|
805 |
-
next_role = "Engineering Manager"
|
806 |
-
else:
|
807 |
-
next_role = f"{job_title} Manager"
|
808 |
-
elif next_level == 'director':
|
809 |
-
next_role = f"Director of {job_title}s"
|
810 |
-
elif next_level == 'vp':
|
811 |
-
next_role = f"VP of {job_title}s"
|
812 |
-
elif next_level == 'head':
|
813 |
-
next_role = f"Head of {job_title}"
|
814 |
-
elif next_level == 'chief':
|
815 |
-
if job_title == "Software Engineer":
|
816 |
-
next_role = "CTO (Chief Technology Officer)"
|
817 |
-
elif job_title == "Data Scientist":
|
818 |
-
next_role = "Chief Data Officer"
|
819 |
-
elif job_title == "Product Manager":
|
820 |
-
next_role = "Chief Product Officer"
|
821 |
-
else:
|
822 |
-
next_role = f"Chief {job_title} Officer"
|
823 |
-
else:
|
824 |
-
next_role = f"{next_level.title()} {job_title}"
|
825 |
-
else:
|
826 |
-
next_role = "Executive Leadership or Strategic Advisory roles"
|
827 |
-
|
828 |
-
return f"Based on career progression, the next logical role could be: {next_role}"
|
|
|
1 |
import streamlit as st
|
2 |
import pdfplumber
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import re
|
4 |
import pandas as pd
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
import torch
|
7 |
+
from datetime import datetime
|
8 |
import plotly.express as px
|
9 |
import plotly.graph_objects as go
|
10 |
+
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Display startup message
|
13 |
st.set_page_config(
|
14 |
page_title="Resume Screener & Skill Extractor",
|
15 |
page_icon="📄",
|
16 |
layout="wide"
|
17 |
)
|
18 |
|
19 |
+
st.title("📄 Resume Screener & Skill Extractor")
|
20 |
+
startup_message = st.empty()
|
21 |
+
startup_message.info("Loading dependencies and models... This may take a minute on first run.")
|
22 |
+
|
23 |
+
# Import dependencies with fallbacks
|
24 |
+
try:
|
25 |
+
import spacy
|
26 |
+
spacy_available = True
|
27 |
+
except ImportError:
|
28 |
+
spacy_available = False
|
29 |
+
st.warning("spaCy is not available. Some features will be limited.")
|
30 |
+
|
31 |
+
try:
|
32 |
+
from transformers import pipeline
|
33 |
+
transformers_available = True
|
34 |
+
except ImportError:
|
35 |
+
transformers_available = False
|
36 |
+
st.warning("Transformers is not available. Summary generation will be limited.")
|
37 |
+
|
38 |
+
try:
|
39 |
+
import nltk
|
40 |
+
from nltk.tokenize import word_tokenize
|
41 |
+
nltk_available = True
|
42 |
+
|
43 |
+
# Download required NLTK resources
|
44 |
try:
|
45 |
+
nltk.data.find('tokenizers/punkt')
|
46 |
+
except LookupError:
|
47 |
+
nltk.download('punkt')
|
48 |
+
except ImportError:
|
49 |
+
nltk_available = False
|
50 |
+
st.warning("NLTK is not available. Some text processing features will be limited.")
|
51 |
+
|
52 |
+
# Custom sentence-transformers fallback
|
53 |
+
try:
|
54 |
+
from sentence_transformers import SentenceTransformer
|
55 |
+
try:
|
56 |
+
from sentence_transformers import util as st_util
|
57 |
+
sentence_transformers_available = True
|
58 |
+
except ImportError:
|
59 |
+
# Define our own utility functions
|
60 |
+
class CustomSTUtil:
|
61 |
+
@staticmethod
|
62 |
+
def pytorch_cos_sim(a, b):
|
63 |
+
if not isinstance(a, torch.Tensor):
|
64 |
+
a = torch.tensor(a)
|
65 |
+
if not isinstance(b, torch.Tensor):
|
66 |
+
b = torch.tensor(b)
|
67 |
+
|
68 |
+
if len(a.shape) == 1:
|
69 |
+
a = a.unsqueeze(0)
|
70 |
+
if len(b.shape) == 1:
|
71 |
+
b = b.unsqueeze(0)
|
72 |
+
|
73 |
+
a_norm = torch.nn.functional.normalize(a, p=2, dim=1)
|
74 |
+
b_norm = torch.nn.functional.normalize(b, p=2, dim=1)
|
75 |
+
return torch.mm(a_norm, b_norm.transpose(0, 1))
|
76 |
+
|
77 |
+
st_util = CustomSTUtil()
|
78 |
+
sentence_transformers_available = True
|
79 |
+
except ImportError:
|
80 |
+
sentence_transformers_available = False
|
81 |
+
st.warning("Sentence Transformers is not available. Semantic matching will be disabled.")
|
82 |
|
83 |
+
# Load models with exception handling
|
84 |
@st.cache_resource
|
85 |
def load_models():
|
86 |
+
models = {}
|
|
|
87 |
|
88 |
+
# Load spaCy if available
|
89 |
+
if spacy_available:
|
90 |
+
try:
|
91 |
+
models['nlp'] = spacy.load("en_core_web_sm")
|
92 |
+
except OSError:
|
93 |
+
try:
|
94 |
+
import subprocess
|
95 |
+
import sys
|
96 |
+
subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
|
97 |
+
models['nlp'] = spacy.load("en_core_web_sm")
|
98 |
+
except Exception as e:
|
99 |
+
st.warning(f"Could not load spaCy model: {e}")
|
100 |
+
models['nlp'] = None
|
101 |
+
else:
|
102 |
+
models['nlp'] = None
|
103 |
|
104 |
+
# Load summarizer if transformers available
|
105 |
+
if transformers_available:
|
106 |
+
try:
|
107 |
+
models['summarizer'] = pipeline("summarization", model="facebook/bart-large-cnn")
|
108 |
+
except Exception as e:
|
109 |
+
st.warning(f"Could not load summarizer model: {e}")
|
110 |
+
# Simple fallback summarizer
|
111 |
+
models['summarizer'] = lambda text, **kwargs: [{"summary_text": ". ".join(text.split(". ")[:5]) + "."}]
|
112 |
+
else:
|
113 |
+
# Simple fallback summarizer
|
114 |
+
models['summarizer'] = lambda text, **kwargs: [{"summary_text": ". ".join(text.split(". ")[:5]) + "."}]
|
|
|
|
|
115 |
|
116 |
+
# Load sentence transformer if available
|
117 |
+
if sentence_transformers_available:
|
118 |
+
try:
|
119 |
+
models['sentence_model'] = SentenceTransformer('paraphrase-MiniLM-L6-v2')
|
120 |
+
except Exception as e:
|
121 |
+
st.warning(f"Could not load sentence transformer model: {e}")
|
122 |
+
models['sentence_model'] = None
|
123 |
+
else:
|
124 |
+
models['sentence_model'] = None
|
125 |
+
|
126 |
+
return models
|
127 |
|
128 |
+
# Job descriptions dictionary
|
129 |
job_descriptions = {
|
130 |
"Software Engineer": {
|
131 |
"skills": ["python", "java", "javascript", "sql", "algorithms", "data structures",
|
|
|
162 |
"Mid-level": "3-5 years of experience, model development, feature engineering",
|
163 |
"Senior": "6+ years of experience, advanced ML techniques, research experience"
|
164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
}
|
166 |
}
|
167 |
|
168 |
+
# Core functionality
|
169 |
def extract_text_from_pdf(pdf_file):
|
170 |
+
"""Extract text from PDF file."""
|
171 |
text = ""
|
172 |
+
try:
|
173 |
+
with pdfplumber.open(pdf_file) as pdf:
|
174 |
+
for page in pdf.pages:
|
175 |
+
text += page.extract_text() or ""
|
176 |
+
except Exception as e:
|
177 |
+
st.error(f"Error extracting text from PDF: {e}")
|
178 |
return text
|
179 |
|
180 |
+
def extract_skills(text, job_title, nlp=None):
|
181 |
+
"""Extract skills from resume text."""
|
|
|
182 |
found_skills = []
|
183 |
required_skills = job_descriptions[job_title]["skills"]
|
184 |
|
185 |
+
# Simple keyword matching (no NLP needed)
|
186 |
for skill in required_skills:
|
187 |
+
if skill.lower() in text.lower():
|
188 |
found_skills.append(skill)
|
189 |
|
190 |
+
return found_skills
|
191 |
+
|
192 |
+
def extract_experience(text):
|
193 |
+
"""Extract work experience from resume text."""
|
194 |
+
experiences = []
|
195 |
+
|
196 |
+
# Define regex pattern for experiences
|
197 |
+
experience_pattern = r"(?i)(\w+[\w\s&,.']+)\s*(?:[-|•]|\bat\b)\s*([A-Za-z][\w\s&,.']+)\s*(?:[-|•]|\bfrom\b)\s*(\d{4}(?:\s*[-–]\s*(?:\d{4}|present|current)))"
|
198 |
+
|
199 |
+
matches = re.finditer(experience_pattern, text)
|
200 |
+
for match in matches:
|
201 |
+
company = match.group(1).strip()
|
202 |
+
role = match.group(2).strip()
|
203 |
+
duration = match.group(3).strip()
|
204 |
+
|
205 |
+
# Process dates
|
206 |
+
try:
|
207 |
+
date_parts = re.split(r'[-–]', duration)
|
208 |
+
start_year = int(date_parts[0].strip())
|
209 |
+
|
210 |
+
if len(date_parts) > 1 and 'present' not in date_parts[1].lower() and 'current' not in date_parts[1].lower():
|
211 |
+
end_year = int(date_parts[1].strip())
|
212 |
+
end_date = datetime(end_year, 12, 31)
|
213 |
+
else:
|
214 |
+
end_year = datetime.now().year
|
215 |
+
end_date = datetime.now()
|
216 |
+
|
217 |
+
start_date = datetime(start_year, 1, 1)
|
218 |
+
duration_months = (end_date.year - start_date.year) * 12 + (end_date.month - start_date.month)
|
219 |
+
|
220 |
+
experiences.append({
|
221 |
+
'company': company,
|
222 |
+
'role': role,
|
223 |
+
'start_date': start_date,
|
224 |
+
'end_date': end_date,
|
225 |
+
'duration_months': duration_months
|
226 |
+
})
|
227 |
+
except:
|
228 |
+
experiences.append({
|
229 |
+
'company': company,
|
230 |
+
'role': role,
|
231 |
+
'duration': duration
|
232 |
+
})
|
233 |
+
|
234 |
+
return experiences
|
235 |
+
|
236 |
+
def analyze_resume(text, job_title, models):
|
237 |
+
"""Analyze resume text."""
|
238 |
+
# Extract skills
|
239 |
+
found_skills = extract_skills(text, job_title, models.get('nlp'))
|
240 |
+
|
241 |
# Generate summary
|
242 |
+
if models.get('summarizer'):
|
243 |
+
try:
|
244 |
+
summary = models['summarizer'](text[:3000], max_length=150, min_length=50, do_sample=False)[0]["summary_text"]
|
245 |
+
except Exception as e:
|
246 |
+
st.warning(f"Error generating summary: {e}")
|
247 |
+
summary = text[:500] + "..."
|
248 |
+
else:
|
249 |
+
summary = text[:500] + "..."
|
250 |
|
251 |
+
# Extract work experience
|
252 |
experiences = extract_experience(text)
|
253 |
|
254 |
# Calculate semantic match score
|
255 |
+
match_score = 0
|
256 |
+
if models.get('sentence_model') and sentence_transformers_available:
|
257 |
+
try:
|
258 |
+
resume_embedding = models['sentence_model'].encode(text[:5000], convert_to_tensor=True)
|
259 |
+
job_embedding = models['sentence_model'].encode(job_descriptions[job_title]["description"], convert_to_tensor=True)
|
260 |
+
|
261 |
+
match_score = float(st_util.pytorch_cos_sim(resume_embedding, job_embedding)[0][0]) * 100
|
262 |
+
except Exception as e:
|
263 |
+
st.warning(f"Error calculating semantic match: {e}")
|
264 |
+
else:
|
265 |
+
# Fallback to keyword-based score
|
266 |
+
match_score = (len(found_skills) / len(job_descriptions[job_title]["skills"])) * 100
|
267 |
|
268 |
+
# Calculate seniority level
|
269 |
+
years_exp = sum(exp.get('duration_months', 0) for exp in experiences if 'duration_months' in exp) / 12
|
270 |
|
271 |
+
if years_exp < 3:
|
272 |
+
seniority = "Junior"
|
273 |
+
elif years_exp < 6:
|
274 |
+
seniority = "Mid-level"
|
275 |
+
else:
|
276 |
+
seniority = "Senior"
|
277 |
|
278 |
+
# Detect skill levels
|
279 |
+
skill_levels = {}
|
280 |
+
for skill in found_skills:
|
281 |
+
# Default level
|
282 |
+
skill_levels[skill] = "intermediate"
|
283 |
+
|
284 |
+
# Look for advanced indicators
|
285 |
+
advanced_patterns = [
|
286 |
+
f"expert in {skill}",
|
287 |
+
f"advanced {skill}",
|
288 |
+
f"extensive experience with {skill}"
|
289 |
+
]
|
290 |
+
if any(pattern in text.lower() for pattern in advanced_patterns):
|
291 |
+
skill_levels[skill] = "advanced"
|
292 |
+
|
293 |
+
# Look for basic indicators
|
294 |
+
basic_patterns = [
|
295 |
+
f"familiar with {skill}",
|
296 |
+
f"basic knowledge of {skill}",
|
297 |
+
f"introduced to {skill}"
|
298 |
+
]
|
299 |
+
if any(pattern in text.lower() for pattern in basic_patterns):
|
300 |
+
skill_levels[skill] = "basic"
|
301 |
+
|
302 |
+
# Check for inconsistencies in timeline
|
303 |
+
inconsistencies = []
|
304 |
+
if len(experiences) >= 2:
|
305 |
+
# Sort experiences by start date
|
306 |
+
sorted_exps = sorted(
|
307 |
+
[exp for exp in experiences if 'start_date' in exp],
|
308 |
+
key=lambda x: x['start_date']
|
309 |
+
)
|
310 |
+
|
311 |
+
# Check for overlaps
|
312 |
+
for i in range(len(sorted_exps) - 1):
|
313 |
+
current = sorted_exps[i]
|
314 |
+
next_exp = sorted_exps[i+1]
|
315 |
+
|
316 |
+
if current['end_date'] > next_exp['start_date']:
|
317 |
+
inconsistencies.append({
|
318 |
+
'type': 'overlap',
|
319 |
+
'description': f"Overlapping roles at {current['company']} and {next_exp['company']}"
|
320 |
+
})
|
321 |
|
322 |
+
# Generate a simple career prediction
|
323 |
+
career_prediction = predict_career_path(seniority, job_title)
|
324 |
|
325 |
return {
|
326 |
'found_skills': found_skills,
|
327 |
+
'skill_levels': skill_levels,
|
328 |
+
'summary': summary,
|
329 |
'experiences': experiences,
|
330 |
'match_score': match_score,
|
331 |
'seniority': seniority,
|
332 |
+
'years_experience': years_exp,
|
|
|
333 |
'inconsistencies': inconsistencies,
|
|
|
334 |
'career_prediction': career_prediction
|
335 |
}
|
336 |
|
337 |
+
def predict_career_path(seniority, job_title):
|
338 |
+
"""Generate a simple career prediction."""
|
339 |
+
if seniority == "Junior":
|
340 |
+
return f"Next potential role: Senior {job_title}"
|
341 |
+
elif seniority == "Mid-level":
|
342 |
+
roles = {
|
343 |
+
"Software Engineer": "Team Lead, Technical Lead, or Engineering Manager",
|
344 |
+
"Data Scientist": "Senior Data Scientist or Data Science Lead",
|
345 |
+
"Interaction Designer": "Senior Designer or UX Lead"
|
346 |
+
}
|
347 |
+
return f"Next potential roles: {roles.get(job_title, f'Senior {job_title}')}"
|
348 |
+
else: # Senior
|
349 |
+
roles = {
|
350 |
+
"Software Engineer": "Engineering Manager, Software Architect, or CTO",
|
351 |
+
"Data Scientist": "Head of Data Science, ML Engineering Manager, or Chief Data Officer",
|
352 |
+
"Interaction Designer": "Design Director, Head of UX, or VP of Design"
|
353 |
+
}
|
354 |
+
return f"Next potential roles: {roles.get(job_title, f'Director of {job_title}')}"
|
355 |
+
|
356 |
def generate_career_advice(resume_text, job_title, found_skills, missing_skills):
|
357 |
+
"""Generate career advice based on resume analysis."""
|
358 |
+
advice = f"""## Career Development Plan for {job_title}
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
|
360 |
+
### Skills to Develop
|
361 |
|
362 |
+
The following skills would strengthen your profile for this position:
|
363 |
|
364 |
+
"""
|
365 |
+
|
366 |
+
for skill in missing_skills:
|
367 |
+
advice += f"- **{skill.title()}**: "
|
368 |
+
|
369 |
+
if skill == "python":
|
370 |
+
advice += "Take online courses like Coursera's Python for Everybody or follow tutorials on Real Python."
|
371 |
+
elif skill == "java":
|
372 |
+
advice += "Complete the Oracle Java Certification or contribute to open-source Java projects."
|
373 |
+
elif skill == "javascript":
|
374 |
+
advice += "Build interactive web applications using modern frameworks like React or Vue."
|
375 |
+
elif skill == "cloud":
|
376 |
+
advice += "Get hands-on experience with AWS, Azure, or GCP through their free tier offerings."
|
377 |
+
elif "algorithm" in skill or "data structure" in skill:
|
378 |
+
advice += "Practice on platforms like LeetCode or HackerRank and study algorithm design principles."
|
379 |
+
elif "ui" in skill or "ux" in skill:
|
380 |
+
advice += "Create a portfolio of design work and study interaction design principles."
|
381 |
+
elif "machine learning" in skill:
|
382 |
+
advice += "Take Andrew Ng's Machine Learning course on Coursera and work on ML projects with real datasets."
|
383 |
+
else:
|
384 |
+
advice += f"Research and practice this skill through online courses, tutorials, and hands-on projects."
|
385 |
+
|
386 |
+
advice += "\n\n"
|
387 |
+
|
388 |
+
advice += f"""
|
389 |
+
### Project Ideas
|
390 |
|
391 |
+
Consider these projects to showcase your skills for a {job_title} position:
|
392 |
|
393 |
+
"""
|
394 |
+
|
395 |
+
if job_title == "Software Engineer":
|
396 |
+
advice += """
|
397 |
+
1. **Full-Stack Web Application**: Build a complete web app with frontend, backend, and database
|
398 |
+
2. **API Service**: Create a RESTful or GraphQL API with proper authentication and documentation
|
399 |
+
3. **Open Source Contribution**: Contribute to relevant open-source projects in your area of interest
|
400 |
+
"""
|
401 |
+
elif job_title == "Data Scientist":
|
402 |
+
advice += """
|
403 |
+
1. **Predictive Model**: Build and deploy a machine learning model that solves a real-world problem
|
404 |
+
2. **Data Dashboard**: Create an interactive visualization dashboard for complex datasets
|
405 |
+
3. **Natural Language Processing**: Develop a text classification or sentiment analysis project
|
406 |
+
"""
|
407 |
+
elif job_title == "Interaction Designer":
|
408 |
+
advice += """
|
409 |
+
1. **Design System**: Create a comprehensive design system with components and usage guidelines
|
410 |
+
2. **UX Case Study**: Document your design process for a real or fictional product improvement
|
411 |
+
3. **Interactive Prototype**: Design a fully functional prototype that demonstrates your interaction design skills
|
412 |
+
"""
|
413 |
+
|
414 |
+
advice += """
|
415 |
+
### Learning Resources
|
416 |
|
417 |
+
- **Online Platforms**: Coursera, Udemy, Pluralsight, LinkedIn Learning
|
418 |
+
- **Practice Sites**: GitHub, HackerRank, LeetCode, Kaggle
|
419 |
+
- **Communities**: Stack Overflow, Reddit programming communities, relevant Discord servers
|
|
|
420 |
"""
|
421 |
+
|
422 |
+
return advice
|
423 |
|
424 |
+
# Load models
|
425 |
+
models = load_models()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
+
# Clear startup message
|
428 |
+
startup_message.empty()
|
429 |
|
430 |
+
# App description
|
431 |
st.markdown("""
|
432 |
This app helps recruiters analyze resumes by:
|
433 |
- Extracting relevant skills for specific job positions
|
|
|
460 |
text = extract_text_from_pdf(uploaded_file)
|
461 |
|
462 |
# Analyze resume
|
463 |
+
analysis_results = analyze_resume(text, job_title, models)
|
464 |
|
465 |
# Calculate missing skills
|
466 |
missing_skills = [skill for skill in job_descriptions[job_title]["skills"]
|
467 |
+
if skill not in analysis_results['found_skills']]
|
468 |
|
469 |
# Display results in tabs
|
470 |
+
tab1, tab2, tab3, tab4 = st.tabs([
|
471 |
"📊 Skills Match",
|
472 |
"📝 Resume Summary",
|
473 |
"🎯 Skills Gap",
|
|
|
|
|
474 |
"🚀 Career Advice"
|
475 |
])
|
476 |
|
477 |
with tab1:
|
478 |
+
# Create two columns
|
479 |
col1, col2 = st.columns(2)
|
480 |
|
481 |
with col1:
|
482 |
# Display matched skills
|
483 |
st.subheader("🎯 Matched Skills")
|
484 |
+
if analysis_results['found_skills']:
|
485 |
+
for skill in analysis_results['found_skills']:
|
486 |
# Show skill with proficiency level
|
487 |
+
level = analysis_results['skill_levels'].get(skill, 'intermediate')
|
488 |
level_emoji = "🟢" if level == 'advanced' else "🟡" if level == 'intermediate' else "🟠"
|
489 |
st.success(f"{level_emoji} {skill.title()} ({level.title()})")
|
490 |
|
491 |
# Calculate match percentage
|
492 |
+
match_percentage = len(analysis_results['found_skills']) / len(job_descriptions[job_title]["skills"]) * 100
|
493 |
st.metric("Skills Match", f"{match_percentage:.1f}%")
|
494 |
else:
|
495 |
st.warning("No direct skill matches found.")
|
|
|
497 |
with col2:
|
498 |
# Display semantic match score
|
499 |
st.subheader("💡 Semantic Match")
|
500 |
+
st.metric("Overall Match Score", f"{analysis_results['match_score']:.1f}%")
|
501 |
|
502 |
# Display must-have skills match
|
503 |
must_have_skills = job_descriptions[job_title]["must_have"]
|
504 |
+
must_have_count = sum(1 for skill in must_have_skills if skill in analysis_results['found_skills'])
|
505 |
must_have_percentage = (must_have_count / len(must_have_skills)) * 100
|
506 |
|
507 |
st.write("Must-have skills:")
|
|
|
510 |
|
511 |
# Professional level assessment
|
512 |
st.subheader("🧠 Seniority Assessment")
|
513 |
+
st.info(f"**{analysis_results['seniority']}** ({analysis_results['years_experience']:.1f} years equivalent experience)")
|
514 |
+
st.write(job_descriptions[job_title]["seniority_levels"][analysis_results['seniority']])
|
515 |
|
516 |
with tab2:
|
517 |
# Display resume summary
|
518 |
st.subheader("📝 Resume Summary")
|
519 |
+
st.write(analysis_results['summary'])
|
520 |
|
521 |
# Display experience timeline
|
522 |
st.subheader("⏳ Experience Timeline")
|
523 |
+
if analysis_results['experiences']:
|
524 |
# Convert experiences to dataframe for display
|
525 |
exp_data = []
|
526 |
+
for exp in analysis_results['experiences']:
|
527 |
if 'start_date' in exp and 'end_date' in exp:
|
528 |
exp_data.append({
|
529 |
'Company': exp['company'],
|
|
|
544 |
st.dataframe(exp_df)
|
545 |
|
546 |
# Create a timeline visualization if dates are available
|
547 |
+
timeline_data = [exp for exp in analysis_results['experiences'] if 'start_date' in exp and 'end_date' in exp]
|
548 |
+
if timeline_data and len(timeline_data) > 0:
|
549 |
+
try:
|
550 |
+
# Sort by start date
|
551 |
+
timeline_data = sorted(timeline_data, key=lambda x: x['start_date'])
|
552 |
+
|
553 |
+
# Create figure
|
554 |
+
fig = go.Figure()
|
555 |
+
|
556 |
+
for i, exp in enumerate(timeline_data):
|
557 |
+
fig.add_trace(go.Bar(
|
558 |
+
x=[(exp['end_date'] - exp['start_date']).days / 30], # Duration in months
|
559 |
+
y=[exp['company']],
|
560 |
+
orientation='h',
|
561 |
+
name=exp['role'],
|
562 |
+
hovertext=f"{exp['role']} at {exp['company']}",
|
563 |
+
marker=dict(color=px.colors.qualitative.Plotly[i % len(px.colors.qualitative.Plotly)])
|
564 |
+
))
|
565 |
+
|
566 |
+
fig.update_layout(
|
567 |
+
title="Career Timeline",
|
568 |
+
xaxis_title="Duration (months)",
|
569 |
+
yaxis_title="Company",
|
570 |
+
height=400,
|
571 |
+
margin=dict(l=0, r=0, b=0, t=30)
|
572 |
+
)
|
573 |
+
|
574 |
+
st.plotly_chart(fig, use_container_width=True)
|
575 |
+
except Exception as e:
|
576 |
+
st.warning(f"Could not create timeline visualization: {e}")
|
577 |
else:
|
578 |
st.warning("No work experience data could be extracted.")
|
579 |
|
|
|
598 |
|
599 |
# Show must-have skills that are missing
|
600 |
missing_must_have = [skill for skill in job_descriptions[job_title]["must_have"]
|
601 |
+
if skill not in analysis_results['found_skills']]
|
602 |
|
603 |
if missing_must_have:
|
604 |
st.error("**Critical Skills Missing:**")
|
|
|
611 |
|
612 |
# Show nice-to-have skills gap
|
613 |
missing_nice_to_have = [skill for skill in job_descriptions[job_title]["nice_to_have"]
|
614 |
+
if skill not in analysis_results['found_skills']]
|
615 |
|
616 |
if missing_nice_to_have:
|
617 |
st.warning("**Nice-to-Have Skills Missing:**")
|
|
|
619 |
st.write(f"- {skill.title()}")
|
620 |
else:
|
621 |
st.success("Candidate has all the nice-to-have skills!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
622 |
|
623 |
+
# Display career trajectory
|
624 |
+
st.subheader("👨💼 Career Trajectory")
|
625 |
+
st.info(analysis_results['career_prediction'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
|
627 |
+
with tab4:
|
628 |
# Display career advice
|
629 |
st.subheader("🚀 Career Advice and Project Recommendations")
|
630 |
|
631 |
if st.button("Generate Career Advice"):
|
632 |
with st.spinner("Generating personalized career advice..."):
|
633 |
+
advice = generate_career_advice(text, job_title, analysis_results['found_skills'], missing_skills)
|
634 |
st.markdown(advice)
|
635 |
|
636 |
except Exception as e:
|
637 |
st.error(f"An error occurred while processing the resume: {str(e)}")
|
638 |
+
st.exception(e)
|
639 |
|
640 |
# Add footer
|
641 |
st.markdown("---")
|
642 |
+
st.markdown("Made with ❤️ using Streamlit and Hugging Face")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,24 +1,22 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
spacy==3.5.
|
4 |
-
transformers==4.28.1
|
5 |
-
torch==1.13.1
|
6 |
-
huggingface-hub==0.14.1
|
7 |
sentence-transformers==2.2.2
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
pandas==1.5.3
|
11 |
numpy==1.24.3
|
12 |
matplotlib==3.7.1
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
scikit-learn==1.0.2
|
18 |
-
scipy==1.8.1
|
19 |
-
dateparser==1.1.8
|
20 |
-
python-Levenshtein==0.21.1
|
21 |
-
networkx==2.8.8
|
22 |
-
faiss-cpu==1.7.4
|
23 |
-
beautifulsoup4==4.12.2
|
24 |
-
requests==2.31.0
|
|
|
1 |
+
# Core dependencies - order matters!
|
2 |
+
pydantic==1.10.8
|
3 |
+
spacy==3.5.0
|
|
|
|
|
|
|
4 |
sentence-transformers==2.2.2
|
5 |
+
torch==1.13.1
|
6 |
+
transformers==4.28.1
|
7 |
+
|
8 |
+
# PDF processing
|
9 |
+
pdfplumber==0.9.0
|
10 |
+
|
11 |
+
# Web UI
|
12 |
+
streamlit==1.22.0
|
13 |
+
|
14 |
+
# Data processing
|
15 |
pandas==1.5.3
|
16 |
numpy==1.24.3
|
17 |
matplotlib==3.7.1
|
18 |
+
plotly==5.14.1
|
19 |
+
|
20 |
+
# Utilities
|
21 |
+
nltk==3.8.1
|
22 |
+
scikit-learn==1.0.2
|
|
|
|
|
|
|
|
|
|
|
|
|
|