Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,8 @@ def preprocess(text):
|
|
37 |
def synonym_match(job_desc, resume):
|
38 |
match_count = 0
|
39 |
total_keywords = 0
|
|
|
|
|
40 |
|
41 |
for key, variants in synonyms.items():
|
42 |
job_contains = any(term in job_desc for term in variants) or key in job_desc
|
@@ -46,18 +48,21 @@ def synonym_match(job_desc, resume):
|
|
46 |
total_keywords += 1
|
47 |
if resume_contains:
|
48 |
match_count += 1
|
|
|
|
|
|
|
49 |
|
50 |
-
return (match_count / total_keywords) * 100 if total_keywords > 0 else 0
|
51 |
|
52 |
def keyword_match(job_desc, resume):
|
53 |
job_keywords = set(re.findall(r'\b\w+\b', job_desc))
|
54 |
resume_keywords = set(re.findall(r'\b\w+\b', resume))
|
55 |
common_keywords = job_keywords.intersection(resume_keywords)
|
56 |
-
return (len(common_keywords) / len(job_keywords)) * 100 if job_keywords else 0
|
57 |
|
58 |
-
st.title("
|
59 |
|
60 |
-
job_description = st.text_area("Paste
|
61 |
resume_text = st.text_area("Paste your resume here:", height=200)
|
62 |
|
63 |
if st.button("Compare"):
|
@@ -71,17 +76,22 @@ if st.button("Compare"):
|
|
71 |
resume_embedding = model.encode(processed_resume)
|
72 |
similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100
|
73 |
|
74 |
-
# Calculate keyword-based similarity
|
75 |
-
keyword_score = keyword_match(processed_job_desc, processed_resume)
|
76 |
|
77 |
-
# Calculate synonym-based similarity
|
78 |
-
synonym_score = synonym_match(processed_job_desc, processed_resume)
|
79 |
|
80 |
# Combine scores (adjusting weights as needed)
|
81 |
overall_score = (similarity_score * 0.5) + (keyword_score * 0.3) + (synonym_score * 0.2)
|
82 |
|
|
|
83 |
st.write(f"**Overall Similarity Score:** {overall_score:.2f}%")
|
84 |
|
|
|
|
|
|
|
|
|
85 |
# Adjusted feedback based on combined score
|
86 |
if overall_score > 80:
|
87 |
st.success("Excellent match! Your resume closely aligns with the job description.")
|
@@ -94,4 +104,4 @@ if st.button("Compare"):
|
|
94 |
else:
|
95 |
st.error("Very low match. Your resume is significantly different from the job description. Major revisions may be needed.")
|
96 |
else:
|
97 |
-
st.error("Please paste both the job description and your resume to proceed.")
|
|
|
37 |
def synonym_match(job_desc, resume):
|
38 |
match_count = 0
|
39 |
total_keywords = 0
|
40 |
+
matched_keywords = set()
|
41 |
+
missing_keywords = set()
|
42 |
|
43 |
for key, variants in synonyms.items():
|
44 |
job_contains = any(term in job_desc for term in variants) or key in job_desc
|
|
|
48 |
total_keywords += 1
|
49 |
if resume_contains:
|
50 |
match_count += 1
|
51 |
+
matched_keywords.add(key)
|
52 |
+
else:
|
53 |
+
missing_keywords.add(key)
|
54 |
|
55 |
+
return (match_count / total_keywords) * 100 if total_keywords > 0 else 0, list(matched_keywords)[:5], list(missing_keywords)[:5]
|
56 |
|
57 |
def keyword_match(job_desc, resume):
|
58 |
job_keywords = set(re.findall(r'\b\w+\b', job_desc))
|
59 |
resume_keywords = set(re.findall(r'\b\w+\b', resume))
|
60 |
common_keywords = job_keywords.intersection(resume_keywords)
|
61 |
+
return (len(common_keywords) / len(job_keywords)) * 100 if job_keywords else 0, list(common_keywords)[:5]
|
62 |
|
63 |
+
st.title("Resume and Job Description Similarity Checker")
|
64 |
|
65 |
+
job_description = st.text_area("Paste a job description here:", height=200)
|
66 |
resume_text = st.text_area("Paste your resume here:", height=200)
|
67 |
|
68 |
if st.button("Compare"):
|
|
|
76 |
resume_embedding = model.encode(processed_resume)
|
77 |
similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100
|
78 |
|
79 |
+
# Calculate keyword-based similarity and matched keywords
|
80 |
+
keyword_score, matched_keywords = keyword_match(processed_job_desc, processed_resume)
|
81 |
|
82 |
+
# Calculate synonym-based similarity and missing skills
|
83 |
+
synonym_score, synonym_matches, synonym_misses = synonym_match(processed_job_desc, processed_resume)
|
84 |
|
85 |
# Combine scores (adjusting weights as needed)
|
86 |
overall_score = (similarity_score * 0.5) + (keyword_score * 0.3) + (synonym_score * 0.2)
|
87 |
|
88 |
+
# Display the overall similarity score
|
89 |
st.write(f"**Overall Similarity Score:** {overall_score:.2f}%")
|
90 |
|
91 |
+
# Display matched keywords and missing skills
|
92 |
+
st.write("**Matched Keywords:**", ", ".join(matched_keywords + synonym_matches)[:5])
|
93 |
+
st.write("**Missing Skills to Consider Adding:**", ", ".join(synonym_misses)[:5])
|
94 |
+
|
95 |
# Adjusted feedback based on combined score
|
96 |
if overall_score > 80:
|
97 |
st.success("Excellent match! Your resume closely aligns with the job description.")
|
|
|
104 |
else:
|
105 |
st.error("Very low match. Your resume is significantly different from the job description. Major revisions may be needed.")
|
106 |
else:
|
107 |
+
st.error("Please paste both the job description and your resume to proceed.")
|