Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ st.subheader("Job Description", divider="red")
|
|
47 |
txt = st.text_area("Paste the job description and then press Ctrl + Enter", key="text 1")
|
48 |
job = pd.Series(txt, name="Text")
|
49 |
|
50 |
-
st.subheader("Applicant
|
51 |
if 'upload_count' not in st.session_state:
|
52 |
st.session_state['upload_count'] = 0
|
53 |
|
@@ -86,11 +86,79 @@ else:
|
|
86 |
|
87 |
|
88 |
|
|
|
|
|
|
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
|
92 |
|
|
|
|
|
|
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
|
96 |
|
|
|
47 |
txt = st.text_area("Paste the job description and then press Ctrl + Enter", key="text 1")
|
48 |
job = pd.Series(txt, name="Text")
|
49 |
|
50 |
+
st.subheader("Applicant Resume 1", divider="green")
|
51 |
if 'upload_count' not in st.session_state:
|
52 |
st.session_state['upload_count'] = 0
|
53 |
|
|
|
86 |
|
87 |
|
88 |
|
89 |
+
st.subheader("Applicant Resume 2", divider="green")
|
90 |
+
if 'upload_count' not in st.session_state:
|
91 |
+
st.session_state['upload_count'] = 0
|
92 |
|
93 |
+
max_attempts = 3
|
94 |
+
if st.session_state['upload_count'] < max_attempts:
|
95 |
+
uploaded_files = st.file_uploader("Upload Applicant's 2 resume", type="pdf", key="candidate 2")
|
96 |
+
if uploaded_files:
|
97 |
+
st.session_state['upload_count'] += 1
|
98 |
+
|
99 |
+
pdf_reader = PdfReader(uploaded_files)
|
100 |
+
text_data = ""
|
101 |
+
for page in pdf_reader.pages:
|
102 |
+
text_data += page.extract_text()
|
103 |
+
st.text_area("Applicant's 2 resume", value = text_data, height = 300, key = "text 2")
|
104 |
+
data = pd.Series(text_data, name='Text')
|
105 |
+
frames = [job, data]
|
106 |
+
result = pd.concat(frames)
|
107 |
+
|
108 |
+
|
109 |
+
vectorizer = TfidfVectorizer()
|
110 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
111 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
112 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
113 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
114 |
+
|
115 |
+
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
116 |
+
with st.popover("See result"):
|
117 |
+
st.write(f"Similarity of job description with Applicant's 2 resume based on keywords: {similarity_score:.2f}")
|
118 |
+
st.info(
|
119 |
+
"A score closer to 1 (0.80, 0.90) means higher similarity between Applicant's 2 resume and job description. A score closer to 0 (0.20, 0.30) means lower similarity between Applicant's 2 resume and job description.")
|
120 |
+
else:
|
121 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
122 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
123 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
124 |
|
125 |
|
126 |
|
127 |
+
st.subheader("Applicant Resume 3", divider="green")
|
128 |
+
if 'upload_count' not in st.session_state:
|
129 |
+
st.session_state['upload_count'] = 0
|
130 |
|
131 |
+
max_attempts = 3
|
132 |
+
if st.session_state['upload_count'] < max_attempts:
|
133 |
+
uploaded_files = st.file_uploader("Upload Applicant's 3 resume", type="pdf", key="candidate 3")
|
134 |
+
if uploaded_files:
|
135 |
+
st.session_state['upload_count'] += 1
|
136 |
+
|
137 |
+
pdf_reader = PdfReader(uploaded_files)
|
138 |
+
text_data = ""
|
139 |
+
for page in pdf_reader.pages:
|
140 |
+
text_data += page.extract_text()
|
141 |
+
st.text_area("Applicant's 3 resume", value = text_data, height = 300, key = "text 2")
|
142 |
+
data = pd.Series(text_data, name='Text')
|
143 |
+
frames = [job, data]
|
144 |
+
result = pd.concat(frames)
|
145 |
+
|
146 |
+
|
147 |
+
vectorizer = TfidfVectorizer()
|
148 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
149 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
150 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
151 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
152 |
+
|
153 |
+
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
154 |
+
with st.popover("See result"):
|
155 |
+
st.write(f"Similarity of job description with Applicant's 3 resume based on keywords: {similarity_score:.2f}")
|
156 |
+
st.info(
|
157 |
+
"A score closer to 1 (0.80, 0.90) means higher similarity between Applicant's 3 resume and job description. A score closer to 0 (0.20, 0.30) means lower similarity between Applicant's 3 resume and job description.")
|
158 |
+
else:
|
159 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
160 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
161 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
162 |
|
163 |
|
164 |
|