-
Notifications
You must be signed in to change notification settings - Fork 0
/
match.py
63 lines (53 loc) · 2.37 KB
/
match.py
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
import streamlit as st
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.metrics.pairwise import cosine_similarity
import os
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
nltk.download('punkt')
nltk.download('stopwords')
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
# Function to calculate the match percentage between two texts
def calculate_match_percentage(text1, text2):
vectorizer = CountVectorizer().fit_transform([text1, text2])
vectors = vectorizer.toarray()
cosine_sim = cosine_similarity(vectors)
match_percentage = cosine_sim[0, 1] * 100 # Convert to percentage
return match_percentage
def extract_key_terms(text):
stop_words = set(stopwords.words('english'))
word_tokens = word_tokenize(text.lower())
filtered_words = [w for w in word_tokens if not w in stop_words and w.isalpha()]
st.write(filtered_words)
return set(filtered_words)
# Streamlit UI
st.title('Resume_JD Scorer')
# Text areas for user input
resume_text = st.text_area("Paste Your Resume Here")
jd_text = st.text_area("Paste Job Description Here")
if st.button('Match'):
if resume_text and jd_text:
# Calculate the match percentage
match_percentage = calculate_match_percentage(resume_text, jd_text)
st.write(f"Match Percentage: {match_percentage:.2f}%")
# Extracting key terms from JD and checking against the resume
jd_terms = extract_key_terms(jd_text)
st.title('JD terms')
st.write(jd_terms)
resume_terms = extract_key_terms(resume_text)
st.title('Resume terms')
st.write(resume_terms)
missing_terms = jd_terms - resume_terms
if match_percentage >= 80:
st.success("Good Chances of getting your Resume Shortlisted.")
elif 40 <= match_percentage < 80:
st.warning("Good match but can be improved.")
if missing_terms:
st.info(f"Replace words and modify the resume with these key terms from the job description:\n {', '.join(missing_terms)}")
elif match_percentage < 40:
st.error("Poor match.")
if missing_terms:
st.info(f"Replace words and modify the resume with these key terms from the job description:\n {', '.join(missing_terms)}")
else:
st.warning("Please enter both Resume and Job Description.")