Repository navigation
Expand file tree
/
Copy pathapp.py
More file actions
128 lines (106 loc) · 4.45 KB
/
Copy pathapp.py
File metadata and controls
128 lines (106 loc) · 4.45 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import streamlit as st
import pandas as pd
import base64
import io
import matplotlib.pyplot as plt
from matplotlib import style
from PyPDF2 import PdfReader
from collections import Counter
import re
# Use a more aesthetic style for matplotlib
style.use('ggplot')
# ---- Helper Functions ----
def extract_text_from_pdf(uploaded_file):
reader = PdfReader(uploaded_file)
text = ""
for page in reader.pages:
text += page.extract_text() or ""
return text
def analyze_resume(text):
keywords = ['python', 'java', 'sql', 'machine learning', 'data analysis']
# Extract skill mentions from projects (more relevant than general text)
project_keywords = '|'.join(keywords)
project_mentions = re.findall(fr'(?i)\b({project_keywords})\b', text)
skill_distribution = dict(Counter([kw.lower() for kw in project_mentions]))
found_skills = list(skill_distribution.keys())
missing_skills = list(set(keywords) - set(found_skills))
# Improved Skill Score: considers both presence and frequency of skills
total_possible = len(keywords)
presence_score = len(found_skills) / total_possible
freq_score = sum(skill_distribution.values()) / total_possible
skill_score = int((0.5 * presence_score + 0.5 * min(freq_score, 1)) * 100)
# Job roles and courses mapped to each skill
job_role_map = {
'python': ['Python Developer', 'ML Engineer'],
'sql': ['Data Analyst', 'BI Analyst'],
'java': ['Java Developer'],
'machine learning': ['ML Engineer'],
'data analysis': ['Data Scientist']
}
course_map = {
'python': ['Python for Everybody (Coursera)'],
'sql': ['SQL for Data Science (Udemy)'],
'java': ['Java Programming Masterclass (Udemy)'],
'machine learning': ['Intro to ML (Kaggle)', 'ML Specialization (Coursera)'],
'data analysis': ['Data Analytics with Excel (Coursera)']
}
job_suggestions = set()
course_suggestions = set()
for skill in found_skills:
job_suggestions.update(job_role_map.get(skill, []))
course_suggestions.update(course_map.get(skill, []))
return {
'found_skills': found_skills,
'missing_skills': missing_skills,
'skill_score': skill_score,
'skill_distribution': skill_distribution,
'suggested_jobs': list(job_suggestions) or ['Explore internships to gain experience'],
'courses': list(course_suggestions) or ['Consider introductory courses on Coursera/Udemy']
}
# ---- Streamlit UI ----
st.set_page_config(page_title="Resume Analyzer", layout="centered")
st.title("📄 Resume Analyzer")
st.write("Upload your resume (PDF) to receive a detailed analysis of your skills, matching jobs, and suggestions to improve.")
uploaded_file = st.file_uploader("Upload Resume (PDF)", type="pdf")
if uploaded_file:
text = extract_text_from_pdf(uploaded_file)
result = analyze_resume(text)
st.subheader("✅ Resume Analysis Summary")
col1, col2 = st.columns(2)
with col1:
st.metric("Skill Match %", f"{result['skill_score']}%")
st.success("✔️ Found Skills")
st.write(", ".join(result['found_skills']) or "None")
with col2:
st.warning("⚠️ Missing Skills")
st.write(", ".join(result['missing_skills']) or "None")
# --- Skill Relevance Pie Chart ---
st.subheader("📊 Skill Relevance from Projects")
skill_labels = list(result['skill_distribution'].keys())
skill_sizes = list(result['skill_distribution'].values())
if skill_sizes:
fig, ax = plt.subplots(figsize=(6, 6))
wedges, texts, autotexts = ax.pie(
skill_sizes,
labels=skill_labels,
autopct='%1.1f%%',
startangle=140,
colors=plt.cm.Paired.colors,
textprops={'fontsize': 12, 'color': 'black'}
)
ax.axis('equal')
ax.set_title("Skill Distribution in Projects", fontsize=16, fontweight='bold')
st.pyplot(fig)
else:
st.info("No relevant skills mentioned in project descriptions.")
# --- Job Suggestions ---
st.subheader("💼 Recommended Job Roles")
st.write("Based on your skills, you may apply for:")
for job in result['suggested_jobs']:
st.markdown(f"- {job}")
# --- Course Suggestions ---
st.subheader("🎓 Suggested Courses to Improve Your Resume")
for course in result['courses']:
st.markdown(f"- {course}")
else:
st.info("⬆️ Please upload your resume to get started.")