laurenramroop commited on
Commit
d728f53
·
verified ·
1 Parent(s): 6a3b909

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -20
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
- # App title
12
- st.title("Resume and Job Description Similarity Checker")
 
 
 
 
 
 
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
- # Display the similarity score
29
- st.write(f"**Similarity Score:** {similarity_score:.2f}%")
30
-
31
- # Provide feedback based on similarity score
32
- if similarity_score > 80:
33
- st.success("Excellent match! Your resume closely aligns with the job description.")
34
- elif similarity_score > 60:
35
- st.info("Good match! Your resume has relevant information, but you might want to tailor it further.")
36
- elif similarity_score > 40:
37
- st.warning("Partial match. Your resume shows some alignment, but consider adding more relevant skills and experiences.")
 
 
 
38
  else:
39
- st.error("Low match. Your resume might not align well with the job description. Consider revising it to better reflect the job requirements.")
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.")