| 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() |
| |
| 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_wordcloud(' '.join(jp), 'Word Cloud for Job Description Keywords') |
| generate_wordcloud(' '.join(rp), 'Word Cloud for Resume Keywords') |
|
|
| score = calculate_similarity(model, jd, resume) |
| |
| |
| 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) |
|
|
| |
| missing_keywords = set(jp) - set(rp) |
| matching_keywords = set(jp) & set(rp) |
|
|
| |
| 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)) |
|
|
| |
| 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.", ) |
|
|