Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,45 @@
|
|
1 |
import streamlit as st
|
2 |
from sentence_transformers import SentenceTransformer, util
|
|
|
3 |
|
4 |
-
# Cache the model to load it only once
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
return SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
8 |
|
9 |
model = load_model()
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
# Input text areas
|
15 |
job_description = st.text_area("Paste the job description here:", height=200)
|
16 |
resume_text = st.text_area("Paste your resume here:", height=200)
|
17 |
|
18 |
-
# Button to compute similarity
|
19 |
if st.button("Compare"):
|
20 |
if job_description.strip() and resume_text.strip():
|
21 |
-
# Encode both the job description and resume
|
22 |
job_description_embedding = model.encode(job_description)
|
23 |
resume_embedding = model.encode(resume_text)
|
24 |
-
|
25 |
-
# Calculate cosine similarity
|
26 |
similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
38 |
else:
|
39 |
-
st.error("Low match.
|
40 |
else:
|
41 |
st.error("Please paste both the job description and your resume to proceed.")
|
|
|
1 |
import streamlit as st
|
2 |
from sentence_transformers import SentenceTransformer, util
|
3 |
+
import re
|
4 |
|
|
|
5 |
@st.cache_resource
|
6 |
def load_model():
|
7 |
return SentenceTransformer('sentence-transformers/all-mpnet-base-v2')
|
8 |
|
9 |
model = load_model()
|
10 |
|
11 |
+
def keyword_match(job_desc, resume):
|
12 |
+
job_keywords = set(re.findall(r'\b\w+\b', job_desc.lower()))
|
13 |
+
resume_keywords = set(re.findall(r'\b\w+\b', resume.lower()))
|
14 |
+
common_keywords = job_keywords.intersection(resume_keywords)
|
15 |
+
match_ratio = len(common_keywords) / len(job_keywords) * 100
|
16 |
+
return match_ratio
|
17 |
+
|
18 |
+
st.title("Enhanced Resume and Job Description Similarity Checker")
|
19 |
|
|
|
20 |
job_description = st.text_area("Paste the job description here:", height=200)
|
21 |
resume_text = st.text_area("Paste your resume here:", height=200)
|
22 |
|
|
|
23 |
if st.button("Compare"):
|
24 |
if job_description.strip() and resume_text.strip():
|
|
|
25 |
job_description_embedding = model.encode(job_description)
|
26 |
resume_embedding = model.encode(resume_text)
|
|
|
|
|
27 |
similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100
|
28 |
+
keyword_score = keyword_match(job_description, resume_text)
|
29 |
+
|
30 |
+
# Combine scores (weighted or simple average)
|
31 |
+
overall_score = (similarity_score * 0.7) + (keyword_score * 0.3)
|
32 |
+
|
33 |
+
st.write(f"**Similarity Score:** {overall_score:.2f}%")
|
34 |
+
|
35 |
+
# Adjusted feedback
|
36 |
+
if overall_score > 70:
|
37 |
+
st.success("Great match! Your resume aligns well with the job description.")
|
38 |
+
elif overall_score > 50:
|
39 |
+
st.info("Good match! Your resume has relevant information, but it could be tailored a bit more.")
|
40 |
+
elif overall_score > 30:
|
41 |
+
st.warning("Partial match. Your resume shows some alignment, but consider emphasizing relevant skills and experiences.")
|
42 |
else:
|
43 |
+
st.error("Low match. Consider revising your resume to better reflect the job requirements.")
|
44 |
else:
|
45 |
st.error("Please paste both the job description and your resume to proceed.")
|