File size: 3,074 Bytes
647f3d8
8bc65a3
a471b38
289e528
8bc65a3
 
261fd3d
3b4e97f
289e528
647f3d8
d35d353
 
 
 
b2ebc6d
a471b38
 
 
 
 
f6a5cef
8bc65a3
 
 
 
 
 
666e40b
fd797e6
a471b38
 
cfb6690
 
 
ac4a345
 
3f63f11
798a22e
a471b38
f756b50
 
798a22e
2d4c545
798a22e
c4be246
f756b50
2d4c545
8bc65a3
e8bc0f7
e765aef
f756b50
c4be246
e8bc0f7
f756b50
a05fe73
 
f756b50
798a22e
a05fe73
ce0dd91
 
 
 
6a205a6
ce0dd91
e8bc0f7
f756b50
 
 
 
 
 
 
 
ce0dd91
 
 
 
f756b50
 
ce0dd91
c4be246
ce0dd91
 
e8bc0f7
a471b38
f756b50
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
import streamlit as st
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity
from keyphrasetransformer import KeyPhraseTransformer
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import pandas as pd

kp = KeyPhraseTransformer()

@st.cache_resource
def load_model():
    model = SentenceTransformer('all-MiniLM-L6-v2')
    return model

def calculate_similarity(model, text1, text2):
    embedding1 = model.encode([text1])
    embedding2 = model.encode([text2])
    return cosine_similarity(embedding1, embedding2)[0][0]

def generate_wordcloud(text, title):
    wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text)
    plt.figure(figsize=(10, 5))
    plt.imshow(wordcloud, interpolation='bilinear')
    plt.axis('off')
    plt.title(title)
    st.pyplot(plt)

st.title("Resume Analysis Assistant")

model = load_model()
# Set the font size for the "Paste the Job Description" text
st.markdown("<style>#fc1{font-size: 20px !important;}</style>", unsafe_allow_html=True)

jd = st.text_area("Paste the Job Description:", height=150)
resume = st.text_area("Paste Your the Resume:", height=150)

if st.button("GET MATCH SCORE & WORD CLOUD"):
    if jd and resume:
        jp = kp.get_key_phrases(jd)
        rp = kp.get_key_phrases(resume)

        # Generate word clouds for JD and Resume
        generate_wordcloud(' '.join(jp), 'Word Cloud for Job Description Keywords')
        generate_wordcloud(' '.join(rp), 'Word Cloud for Resume Keywords')

        score = calculate_similarity(model, jd, resume)
        # st.write(f"The match score is: {score}", )
        # Display the match score as a percentage
        score_percentage = f"{score * 100:.0f}%"

        st.write("The match score is:")
        st.write(score_percentage, key='match_score')

    else:
        st.write("Please enter both the job description and resume.", )

if st.button("GET KEYWORDS"):
    if jd and resume:
        jp = kp.get_key_phrases(jd)
        rp = kp.get_key_phrases(resume)

        # Find missing and matching keywords
        missing_keywords = set(jp) - set(rp)
        matching_keywords = set(jp) & set(rp)

        # Make sure all arrays have the same length
        max_length = max(len(jp), len(rp), len(matching_keywords), len(missing_keywords))

        jp += [''] * (max_length - len(jp))
        rp += [''] * (max_length - len(rp))
        matching_keywords = list(matching_keywords) + [''] * (max_length - len(matching_keywords))
        missing_keywords = list(missing_keywords) + [''] * (max_length - len(missing_keywords))

        # Display keywords in a table
        keywords_table_data = {
            'Keywords From Job Description': jp,
            'Keywords From Resume': rp,
            'Matching Keywords': matching_keywords,
            'Missing Keywords': missing_keywords
        }

        st.write("Keywords Overview:")
        st.table(pd.DataFrame(keywords_table_data))

    else:
        st.write("Please enter both the job description and resume.", )