nlpblogs commited on
Commit
dac44fa
·
verified ·
1 Parent(s): 0fe0c6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -65
app.py CHANGED
@@ -104,82 +104,81 @@ for i in range(1, 51): # Looping for 2 applicants
104
 
105
  st.divider()
106
 
107
- col1, col2 = st.columns(2)
108
-
109
- with col1:
110
- st.subheader("Visualise Applicant's Profile", divider="blue")
111
- if 'upload_count' not in st.session_state:
112
- st.session_state['upload_count'] = 0
113
- max_attempts = 3
114
- if st.session_state['upload_count'] < max_attempts:
115
- uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf", key = "applicant 1")
116
- if uploaded_files:
117
- st.session_state['upload_count'] += 1
118
-
119
- with st.spinner("Wait for it...", show_time=True):
120
- time.sleep(2)
121
- pdf_reader = PdfReader(uploaded_files)
122
- text_data = ""
123
- for page in pdf_reader.pages:
124
- text_data += page.extract_text()
125
 
126
- data = pd.Series(text_data, name='Text')
127
- frames = [job, data]
128
- result = pd.concat(frames)
129
- model = GLiNER.from_pretrained("urchade/gliner_base")
130
- labels = ["person", "country", "organization", "role", "skills"]
131
- entities = model.predict_entities(text_data, labels)
132
- df = pd.DataFrame(entities)
133
- fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
134
  values='score', color='label')
135
- fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
136
- st.plotly_chart(fig, key = "figure 1")
137
- else:
138
- st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
139
- if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
140
- st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
141
-
142
-
143
-
144
- with col2:
145
- st.subheader("Visualise Similarity", divider="blue")
146
- if 'upload_count' not in st.session_state:
147
- st.session_state['upload_count'] = 0
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", key = "applicant 2")
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', 'Jon Description'],
175
  y=['Resume', '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
 
 
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