nlpblogs commited on
Commit
6bf9880
·
verified ·
1 Parent(s): df13653

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -23
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
- 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)
@@ -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 = "figure 1")
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
- else:
150
- st.warning(f"You have reached the maximum upload attempts ({max_attempts}).")
151
- if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
152
- st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
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