Update app.py
Browse files
app.py
CHANGED
@@ -84,15 +84,6 @@ for i in range(1, 51): # Looping for 2 applicants
|
|
84 |
tfidf_matrix = vectorizer.fit_transform(result)
|
85 |
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
90 |
-
fig = px.imshow(cosine_sim_df, text_auto=True,
|
91 |
-
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
92 |
-
x=['Resume', 'Jon Description'],
|
93 |
-
y=['Resume', 'Job Description'])
|
94 |
-
st.plotly_chart(fig)
|
95 |
-
|
96 |
|
97 |
|
98 |
for j, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
@@ -113,7 +104,7 @@ for i in range(1, 51): # Looping for 2 applicants
|
|
113 |
|
114 |
st.divider()
|
115 |
|
116 |
-
st.subheader("Visualise", divider="blue")
|
117 |
if 'upload_count' not in st.session_state:
|
118 |
st.session_state['upload_count'] = 0
|
119 |
|
@@ -142,9 +133,6 @@ if st.session_state['upload_count'] < max_attempts:
|
|
142 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
143 |
st.plotly_chart(fig)
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
else:
|
149 |
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
150 |
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
@@ -152,7 +140,46 @@ else:
|
|
152 |
|
153 |
|
154 |
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
|
158 |
|
|
|
84 |
tfidf_matrix = vectorizer.fit_transform(result)
|
85 |
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
for j, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
|
|
104 |
|
105 |
st.divider()
|
106 |
|
107 |
+
st.subheader("Visualise Applicant's Profile", divider="blue")
|
108 |
if 'upload_count' not in st.session_state:
|
109 |
st.session_state['upload_count'] = 0
|
110 |
|
|
|
133 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
134 |
st.plotly_chart(fig)
|
135 |
|
|
|
|
|
|
|
136 |
else:
|
137 |
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
138 |
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
|
|
140 |
|
141 |
|
142 |
|
143 |
+
st.divider()
|
144 |
+
st.subheader("Visualise Similarity", divider="blue")
|
145 |
+
if 'upload_count' not in st.session_state:
|
146 |
+
st.session_state['upload_count'] = 0
|
147 |
+
|
148 |
+
max_attempts = 3
|
149 |
+
if st.session_state['upload_count'] < max_attempts:
|
150 |
+
uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf")
|
151 |
+
if uploaded_files:
|
152 |
+
st.session_state['upload_count'] += 1
|
153 |
+
|
154 |
+
with st.spinner("Wait for it...", show_time=True):
|
155 |
+
time.sleep(2)
|
156 |
+
pdf_reader = PdfReader(uploaded_files)
|
157 |
+
text_data = ""
|
158 |
+
for page in pdf_reader.pages:
|
159 |
+
text_data += page.extract_text()
|
160 |
+
|
161 |
+
data = pd.Series(text_data, name='Text')
|
162 |
+
frames = [job, data]
|
163 |
+
result = pd.concat(frames)
|
164 |
+
|
165 |
+
vectorizer = TfidfVectorizer()
|
166 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
167 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
168 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
169 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
170 |
+
|
171 |
+
|
172 |
+
fig = px.imshow(cosine_sim_df, text_auto=True,
|
173 |
+
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
174 |
+
x=['Resume 1', 'Jon Description'],
|
175 |
+
y=['Resume 1', 'Job Description'])
|
176 |
+
st.plotly_chart(fig, key="figure 2")
|
177 |
+
|
178 |
+
|
179 |
+
else:
|
180 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
181 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
182 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
183 |
|
184 |
|
185 |
|