File size: 4,597 Bytes
9ac410d 88d066d b65c592 2955054 b1ed479 2955054 b1ed479 4e89574 b1ed479 4e89574 b1ed479 2955054 b1ed479 0274b27 63bbd4e 7045659 4e89574 7b3f010 63bbd4e 5196b87 63bbd4e 0b36569 4fae0db 0b36569 63bbd4e 0b36569 63bbd4e 0b36569 63bbd4e 0b36569 63bbd4e 3e06760 63bbd4e 0b36569 63bbd4e 3e06760 63bbd4e 3e06760 63bbd4e 50f674a 3e06760 50f674a 63bbd4e 3e06760 63bbd4e 3e06760 63bbd4e 0b36569 63bbd4e 0b36569 04ccb1c 784e033 04ccb1c eea17f0 99f18bc |
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
import streamlit as st
from PyPDF2 import PdfReader
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
from gliner import GLiNER
import plotly.express as px
with st.sidebar:
st.button("DEMO APP", type="primary")
expander = st.expander("**Important notes on the AI Resume Analysis based on Keywords App**")
expander.write('''
**Supported File Formats**
This app accepts files in .pdf formats.
**How to Use**
Paste the job description first. Then, upload the resume of each applicant to retrieve the results. At the bottom of the app, you could upload each applicant's resume to visualize their profile as a treemap chart as well as the results in a matrix heatmap.
**Usage Limits**
You can request results up to 20 times in total.
**Subscription Management**
This demo app offers a one-day subscription, expiring after 24 hours. If you are interested in building your own AI Resume Analysis based on Keywords Web App, we invite you to explore our NLP Web App Store on our website. You can select your desired features, place your order, and we will deliver your custom app within five business days. If you wish to delete your Account with us, please contact us at [email protected]
**Customization**
To change the app's background color to white or black, click the three-dot menu on the right-hand side of your app, go to Settings and then Choose app theme, colors and fonts.
**File Handling and Errors**
The app may display an error message if your file is corrupt, or has other errors.
For any errors or inquiries, please contact us at [email protected]
''')
st.title("AI Resume Analysis based on Keywords App")
st.divider()
job = pd.Series(st.text_area("Paste the job description and then press Ctrl + Enter", key="job_desc"), name="Text")
if 'applicant_data' not in st.session_state:
st.session_state['applicant_data'] = {}
max_attempts = 20
for i in range(1, 3): # Looping for 2 applicants
st.subheader(f"Applicant Resume {i}", divider="green")
applicant_key = f"applicant_{i}"
upload_key = f"candidate_{i}"
if applicant_key not in st.session_state['applicant_data']:
st.session_state['applicant_data'][applicant_key] = {'upload_count': 0, 'uploaded_file': None, 'analysis_done': False}
if st.session_state['applicant_data'][applicant_key]['upload_count'] < max_attempts:
uploaded_file = st.file_uploader(f"Upload Applicant's {i} resume", type="pdf", key=upload_key)
if uploaded_file:
st.session_state['applicant_data'][applicant_key]['uploaded_file'] = uploaded_file
st.session_state['applicant_data'][applicant_key]['upload_count'] += 1
st.session_state['applicant_data'][applicant_key]['analysis_done'] = False # Reset analysis flag
if st.session_state['applicant_data'][applicant_key]['uploaded_file'] and not st.session_state['applicant_data'][applicant_key]['analysis_done']:
pdf_reader = PdfReader(st.session_state['applicant_data'][applicant_key]['uploaded_file'])
text_data = ""
for page in pdf_reader.pages:
text_data += page.extract_text()
with st.expander(f"See Applicant's {i} resume"):
st.write(text_data)
data = pd.Series(text_data, name='Text')
result = pd.concat([job, data])
vectorizer = TfidfVectorizer()
tfidf_matrix = vectorizer.fit_transform(result)
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
st.subheader(f"Similarity Analysis for Applicant {i}")
for j, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
with st.popover("See result"):
st.write(f"Similarity based on keyword: {similarity_score:.2f}")
st.info(
f"A score closer to 1 means higher similarity between Applicant's {i} resume and job description.")
st.session_state['applicant_data'][applicant_key]['analysis_done'] = True
else:
st.warning(f"Applicant {i} has reached the maximum upload attempts ({max_attempts}).")
if st.session_state['applicant_data'][applicant_key]['upload_count'] > 0:
st.info(f"Files uploaded for Applicant {i}: {st.session_state['applicant_data'][applicant_key]['upload_count']} time(s).")
|