File size: 2,309 Bytes
1c6412d
cb632ff
d728f53
cb632ff
 
 
 
 
 
8c8e3c8
d728f53
e8552a6
 
d728f53
e8552a6
d728f53
e8552a6
8c8e3c8
e8552a6
6a3b909
8c8e3c8
6a3b909
 
46a124f
e8552a6
 
6a3b909
46a124f
e8552a6
 
d728f53
e8552a6
 
d728f53
e8552a6
d728f53
e8552a6
46a124f
 
 
 
d728f53
e8552a6
46a124f
 
6a3b909
46a124f
6a3b909
1ae1b13
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
import streamlit as st
from sentence_transformers import SentenceTransformer, util
import re

@st.cache_resource
def load_model():
    return SentenceTransformer('sentence-transformers/all-mpnet-base-v2')

model = load_model()

def keyword_match(job_desc, resume):
    job_keywords = set(re.findall(r'\b\w+\b', job_desc.lower()))
    resume_keywords = set(re.findall(r'\b\w+\b', resume.lower()))
    common_keywords = job_keywords.intersection(resume_keywords)
    return len(common_keywords) / len(job_keywords) * 100 if job_keywords else 0

st.title("Enhanced Resume and Job Description Similarity Checker")

job_description = st.text_area("Paste the job description here:", height=200)
resume_text = st.text_area("Paste your resume here:", height=200)

if st.button("Compare"):
    if job_description.strip() and resume_text.strip():
        # Calculate embeddings-based similarity
        job_description_embedding = model.encode(job_description)
        resume_embedding = model.encode(resume_text)
        similarity_score = util.cos_sim(job_description_embedding, resume_embedding).item() * 100

        # Calculate keyword-based similarity
        keyword_score = keyword_match(job_description, resume_text)
        
        # Combine scores (you could adjust the weights as needed)
        overall_score = (similarity_score * 0.6) + (keyword_score * 0.4)
        
        st.write(f"**Similarity Score:** {overall_score:.2f}%")
        
        # Adjusted grading scale based on combined score
        if overall_score > 80:
            st.success("Excellent match! Your resume closely aligns with the job description.")
        elif overall_score > 65:
            st.info("Strong match! Your resume aligns well, but a few minor tweaks could help.")
        elif overall_score > 50:
            st.warning("Moderate match. Your resume has some relevant information, but consider emphasizing relevant skills.")
        elif overall_score > 35:
            st.error("Low match. Your resume does not align well. Consider revising to highlight key skills.")
        else:
            st.error("Very low match. Your resume is significantly different from the job description. Major revisions may be needed.")
    else:
        st.error("Please paste both the job description and your resume to proceed.")