Update app.py
Browse files
app.py
CHANGED
@@ -103,25 +103,23 @@ for i in range(1, 51): # Looping for 2 applicants
|
|
103 |
|
104 |
|
105 |
st.divider()
|
106 |
-
|
107 |
-
|
108 |
st.subheader("Visualise", divider="blue")
|
|
|
109 |
if 'upload_count' not in st.session_state:
|
110 |
st.session_state['upload_count'] = 0
|
111 |
-
|
112 |
-
|
113 |
if st.session_state['upload_count'] < max_attempts:
|
114 |
-
uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf", key
|
115 |
-
if uploaded_files:
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
data = pd.Series(text_data, name='Text')
|
126 |
frames = [job, data]
|
127 |
result = pd.concat(frames)
|
@@ -132,25 +130,22 @@ if uploaded_files:
|
|
132 |
fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
133 |
values='score', color='label')
|
134 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
135 |
-
st.plotly_chart(fig, key
|
136 |
-
|
137 |
vectorizer = TfidfVectorizer()
|
138 |
tfidf_matrix = vectorizer.fit_transform(result)
|
139 |
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
140 |
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
141 |
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
142 |
|
143 |
-
|
144 |
fig = px.imshow(cosine_sim_df, text_auto=True,
|
145 |
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
146 |
x=['Resume', 'Jon Description'],
|
147 |
y=['Resume', 'Job Description'])
|
148 |
st.plotly_chart(fig, key="figure 2")
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
|
156 |
|
|
|
103 |
|
104 |
|
105 |
st.divider()
|
|
|
|
|
106 |
st.subheader("Visualise", divider="blue")
|
107 |
+
|
108 |
if 'upload_count' not in st.session_state:
|
109 |
st.session_state['upload_count'] = 0
|
110 |
+
max_attempts = 3
|
111 |
+
|
112 |
if st.session_state['upload_count'] < max_attempts:
|
113 |
+
uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf", key="applicant 1")
|
114 |
+
if uploaded_files:
|
115 |
+
st.session_state['upload_count'] += 1
|
116 |
+
with st.spinner("Wait for it...", show_time=True):
|
117 |
+
time.sleep(2)
|
118 |
+
pdf_reader = PdfReader(uploaded_files)
|
119 |
+
text_data = ""
|
120 |
+
for page in pdf_reader.pages:
|
121 |
+
text_data += page.extract_text()
|
122 |
+
|
|
|
123 |
data = pd.Series(text_data, name='Text')
|
124 |
frames = [job, data]
|
125 |
result = pd.concat(frames)
|
|
|
130 |
fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
131 |
values='score', color='label')
|
132 |
fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
|
133 |
+
st.plotly_chart(fig, key="figure 1")
|
|
|
134 |
vectorizer = TfidfVectorizer()
|
135 |
tfidf_matrix = vectorizer.fit_transform(result)
|
136 |
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
137 |
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
138 |
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
139 |
|
|
|
140 |
fig = px.imshow(cosine_sim_df, text_auto=True,
|
141 |
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
142 |
x=['Resume', 'Jon Description'],
|
143 |
y=['Resume', 'Job Description'])
|
144 |
st.plotly_chart(fig, key="figure 2")
|
145 |
+
else:
|
146 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
147 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
148 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
|
|
149 |
|
150 |
|
151 |
|