Update app.py
Browse files
app.py
CHANGED
@@ -104,82 +104,81 @@ for i in range(1, 51): # Looping for 2 applicants
|
|
104 |
|
105 |
st.divider()
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
st.
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
text_data += page.extract_text()
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
values='score', color='label')
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
|
171 |
|
172 |
-
|
173 |
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
174 |
x=['Resume', 'Jon Description'],
|
175 |
y=['Resume', 'Job Description'])
|
176 |
-
|
177 |
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
|
184 |
|
185 |
|
|
|
104 |
|
105 |
st.divider()
|
106 |
|
107 |
+
|
108 |
+
st.subheader("Visualise Applicant's Profile", divider="blue")
|
109 |
+
if 'upload_count' not in st.session_state:
|
110 |
+
st.session_state['upload_count'] = 0
|
111 |
+
|
112 |
+
max_attempts = 3
|
113 |
+
if st.session_state['upload_count'] < max_attempts:
|
114 |
+
uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf", key = "applicant 1")
|
115 |
+
if uploaded_files:
|
116 |
+
st.session_state['upload_count'] += 1
|
117 |
+
|
118 |
+
with st.spinner("Wait for it...", show_time=True):
|
119 |
+
time.sleep(2)
|
120 |
+
pdf_reader = PdfReader(uploaded_files)
|
121 |
+
text_data = ""
|
122 |
+
for page in pdf_reader.pages:
|
123 |
+
text_data += page.extract_text()
|
|
|
124 |
|
125 |
+
data = pd.Series(text_data, name='Text')
|
126 |
+
frames = [job, data]
|
127 |
+
result = pd.concat(frames)
|
128 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
129 |
+
labels = ["person", "country", "organization", "role", "skills"]
|
130 |
+
entities = model.predict_entities(text_data, labels)
|
131 |
+
df = pd.DataFrame(entities)
|
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 = "figure 1")
|
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:
|
139 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
|
144 |
+
st.subheader("Visualise Similarity", divider="blue")
|
145 |
+
if 'upload_count' not in st.session_state:
|
146 |
+
st.session_state['upload_count'] = 0
|
147 |
+
max_attempts = 3
|
148 |
+
if st.session_state['upload_count'] < max_attempts:
|
149 |
+
uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf", key = "applicant 2")
|
150 |
+
if uploaded_files:
|
151 |
+
st.session_state['upload_count'] += 1
|
152 |
+
|
153 |
+
with st.spinner("Wait for it...", show_time=True):
|
154 |
+
time.sleep(2)
|
155 |
+
pdf_reader = PdfReader(uploaded_files)
|
156 |
+
text_data = ""
|
157 |
+
for page in pdf_reader.pages:
|
158 |
+
text_data += page.extract_text()
|
159 |
|
160 |
+
data = pd.Series(text_data, name='Text')
|
161 |
+
frames = [job, data]
|
162 |
+
result = pd.concat(frames)
|
163 |
|
164 |
+
vectorizer = TfidfVectorizer()
|
165 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
166 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
167 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
168 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
169 |
|
170 |
|
171 |
+
fig = px.imshow(cosine_sim_df, text_auto=True,
|
172 |
labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
173 |
x=['Resume', 'Jon Description'],
|
174 |
y=['Resume', 'Job Description'])
|
175 |
+
st.plotly_chart(fig, key="figure 2")
|
176 |
|
177 |
|
178 |
+
else:
|
179 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
|
180 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
181 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
182 |
|
183 |
|
184 |
|