nlpblogs commited on
Commit
f6b2b7f
·
verified ·
1 Parent(s): cd63bad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -31
app.py CHANGED
@@ -111,39 +111,27 @@ if st.session_state['upload_count'] < max_attempts:
111
  uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf")
112
  if uploaded_files:
113
  st.session_state['upload_count'] += 1
114
-
115
- pdf_reader = PdfReader(uploaded_files)
116
- text_data = ""
117
- for page in pdf_reader.pages:
118
- text_data += page.extract_text()
 
 
119
 
120
- data = pd.Series(text_data, name='Text')
121
- frames = [job, data]
122
- result = pd.concat(frames)
123
- model = GLiNER.from_pretrained("urchade/gliner_base")
124
- labels = ["person", "country", "organization", "role", "skills"]
125
- entities = model.predict_entities(text_data, labels)
126
- df = pd.DataFrame(entities)
127
-
128
- tab1, tab2 = st.tabs(["Applicant's Profile", "Similarity"])
129
- with st.spinner("Wait for it...", show_time=True):
130
- with tab1:
131
- fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
132
  values='score', color='label')
133
- fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
134
- st.plotly_chart(fig, key="figure 1")
135
-
136
- with tab2:
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
- fig = px.imshow(cosine_sim_df, text_auto=True,
143
- labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
144
- x=['Resume', 'Jon Description'],
145
- y=['Resume', 'Job Description'])
146
- st.plotly_chart(fig, key="figure 2")
147
 
148
 
149
  else:
 
111
  uploaded_files = st.file_uploader("Upload Applicant's resume", type="pdf")
112
  if uploaded_files:
113
  st.session_state['upload_count'] += 1
114
+
115
+ with st.spinner("Wait for it...", show_time=True):
116
+ time.sleep(2)
117
+ pdf_reader = PdfReader(uploaded_files)
118
+ text_data = ""
119
+ for page in pdf_reader.pages:
120
+ text_data += page.extract_text()
121
 
122
+ data = pd.Series(text_data, name='Text')
123
+ frames = [job, data]
124
+ result = pd.concat(frames)
125
+ model = GLiNER.from_pretrained("urchade/gliner_base")
126
+ labels = ["person", "country", "organization", "role", "skills"]
127
+ entities = model.predict_entities(text_data, labels)
128
+ df = pd.DataFrame(entities)
129
+ fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
 
 
 
 
130
  values='score', color='label')
131
+ fig.update_layout(margin=dict(t=50, l=25, r=25, b=25))
132
+ st.plotly_chart(fig)
133
+
134
+
 
 
 
 
 
 
 
 
 
 
135
 
136
 
137
  else: