Update app.py
Browse files
app.py
CHANGED
@@ -39,6 +39,7 @@ with st.sidebar:
|
|
39 |
|
40 |
''')
|
41 |
|
|
|
42 |
|
43 |
txt = st.text_area("Paste the job description and then press Ctrl + Enter", key = "text 1")
|
44 |
job = pd.Series(txt, name="Text")
|
@@ -111,6 +112,83 @@ if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
|
111 |
|
112 |
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
|
116 |
|
|
|
39 |
|
40 |
''')
|
41 |
|
42 |
+
st.subheader ("Candidate Profile 1, divider = "green")
|
43 |
|
44 |
txt = st.text_area("Paste the job description and then press Ctrl + Enter", key = "text 1")
|
45 |
job = pd.Series(txt, name="Text")
|
|
|
112 |
|
113 |
|
114 |
|
115 |
+
st.subheader ("Candidate Profile 2, divider = "green")
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
if 'upload_count' not in st.session_state:
|
120 |
+
st.session_state['upload_count'] = 0
|
121 |
+
|
122 |
+
max_attempts = 3
|
123 |
+
|
124 |
+
if st.session_state['upload_count'] < max_attempts:
|
125 |
+
uploaded_files = st.file_uploader(
|
126 |
+
"Upload your resume in .pdf format", accept_multiple_files=True, type="pdf", key="candidate 2"
|
127 |
+
)
|
128 |
+
|
129 |
+
if uploaded_files:
|
130 |
+
st.session_state['upload_count'] += 1
|
131 |
+
for uploaded_file in uploaded_files:
|
132 |
+
pdf_reader = PdfReader(uploaded_file)
|
133 |
+
text_data = ""
|
134 |
+
for page in pdf_reader.pages:
|
135 |
+
text_data += page.extract_text()
|
136 |
+
data = pd.Series(text_data, name = 'Text')
|
137 |
+
|
138 |
+
|
139 |
+
frames = [job, data]
|
140 |
+
result = pd.concat(frames)
|
141 |
+
|
142 |
+
|
143 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
144 |
+
labels = ["person", "country","organization", "date", "time", "role", "skills", "year"]
|
145 |
+
entities = model.predict_entities(text_data, labels)
|
146 |
+
df = pd.DataFrame(entities)
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
fig = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
151 |
+
values='score', color='label')
|
152 |
+
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
153 |
+
st.plotly_chart(fig, key = "figure 3")
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
vectorizer = TfidfVectorizer()
|
158 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
159 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
160 |
+
|
161 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
162 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
163 |
+
|
164 |
+
|
165 |
+
|
166 |
+
|
167 |
+
fig = px.imshow(cosine_sim_df, text_auto=True, labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
168 |
+
x=['Resume 2', 'Jon Description'],
|
169 |
+
y=['Resume 2', 'Job Description'])
|
170 |
+
st.plotly_chart(fig, key = "figure 4")
|
171 |
+
|
172 |
+
|
173 |
+
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
174 |
+
st.write(f"Similarity with Candidate Profile. A score closer to 1 means higher similarity. {i + 1}: {similarity_score:.4f}")
|
175 |
+
|
176 |
+
else:
|
177 |
+
st.warning(f"You have reached the maximum URL attempts ({max_attempts}).")
|
178 |
+
|
179 |
+
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
180 |
+
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
181 |
+
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
+
|
187 |
+
|
188 |
+
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
|
193 |
|
194 |
|