Update app.py
Browse files
app.py
CHANGED
@@ -39,150 +39,128 @@ with st.sidebar:
|
|
39 |
|
40 |
''')
|
41 |
|
42 |
-
st.subheader ("Candidate Profile 1", divider = "green")
|
43 |
|
44 |
-
|
|
|
|
|
45 |
job = pd.Series(txt, name="Text")
|
46 |
|
47 |
|
48 |
if 'upload_count' not in st.session_state:
|
49 |
st.session_state['upload_count'] = 0
|
50 |
|
51 |
-
max_attempts =
|
52 |
|
53 |
if st.session_state['upload_count'] < max_attempts:
|
54 |
uploaded_files = st.file_uploader(
|
55 |
-
"Upload your resume",
|
56 |
)
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
st.subheader("Profile of candidate 1")
|
79 |
-
fig1 = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
80 |
values='score', color='label')
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
st.subheader("Measuring similarity between keywords of candidate profile 1 and job description")
|
96 |
-
fig2 = px.imshow(cosine_sim_df, text_auto=True, labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
97 |
x=['Resume 1', 'Jon Description'],
|
98 |
y=['Resume 1', 'Job Description'])
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
st.write("A score closer to 1 (0.80, 0.90) means higher similarity between candidate profile 1 and job description. A score closer to 0 (0.20, 0.30) means lower similarity between candidate profile 1 and job description.")
|
105 |
|
106 |
else:
|
107 |
-
st.warning(f"You have reached the maximum
|
108 |
-
|
109 |
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
110 |
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
111 |
|
112 |
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
st.subheader
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
if 'upload_count' not in st.session_state:
|
121 |
st.session_state['upload_count'] = 0
|
122 |
-
|
123 |
-
max_attempts = 3
|
124 |
-
|
125 |
if st.session_state['upload_count'] < max_attempts:
|
126 |
uploaded_files = st.file_uploader(
|
127 |
-
"Upload your resume in .pdf format",
|
128 |
)
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
fig3 = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
152 |
values='score', color='label')
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
y=['Resume 2', 'Job Description'])
|
171 |
-
st.plotly_chart(fig4, key = "figure 4")
|
172 |
-
|
173 |
-
|
174 |
-
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
175 |
-
st.write(f"Similarity with Candidate Profile. A score closer to 1 means higher similarity. {i + 1}: {similarity_score:.4f}")
|
176 |
-
|
177 |
else:
|
178 |
-
st.warning(f"You have reached the maximum
|
179 |
-
|
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 |
|
185 |
|
|
|
186 |
|
187 |
|
188 |
|
|
|
39 |
|
40 |
''')
|
41 |
|
|
|
42 |
|
43 |
+
st.subheader("Candidate Profile 1", divider = "green")
|
44 |
+
|
45 |
+
txt = st.text_area("Job description", key = "text 1")
|
46 |
job = pd.Series(txt, name="Text")
|
47 |
|
48 |
|
49 |
if 'upload_count' not in st.session_state:
|
50 |
st.session_state['upload_count'] = 0
|
51 |
|
52 |
+
max_attempts = 2
|
53 |
|
54 |
if st.session_state['upload_count'] < max_attempts:
|
55 |
uploaded_files = st.file_uploader(
|
56 |
+
"Upload your resume in .pdf format", type="pdf", key="candidate 1"
|
57 |
)
|
58 |
+
if uploaded_files:
|
59 |
+
st.session_state['upload_count'] += 1
|
60 |
+
for uploaded_file in uploaded_files:
|
61 |
+
pdf_reader = PdfReader(uploaded_file)
|
62 |
+
text_data = ""
|
63 |
+
for page in pdf_reader.pages:
|
64 |
+
text_data += page.extract_text()
|
65 |
+
data = pd.Series(text_data, name = 'Text')
|
66 |
+
frames = [job, data]
|
67 |
+
result = pd.concat(frames)
|
68 |
+
|
69 |
+
|
70 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
71 |
+
labels = ["person", "country","organization", "date", "time", "role", "skills", "year"]
|
72 |
+
entities = model.predict_entities(text_data, labels)
|
73 |
+
df = pd.DataFrame(entities)
|
74 |
+
|
75 |
+
|
76 |
+
fig1 = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
|
|
|
|
|
|
|
|
77 |
values='score', color='label')
|
78 |
+
fig1.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
79 |
+
st.plotly_chart(fig1, key = "figure 1")
|
80 |
+
|
81 |
+
vectorizer = TfidfVectorizer()
|
82 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
83 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
84 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
85 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
86 |
+
|
87 |
+
|
88 |
+
fig2 = px.imshow(cosine_sim_df, text_auto=True, labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
|
|
|
|
|
|
|
|
|
|
89 |
x=['Resume 1', 'Jon Description'],
|
90 |
y=['Resume 1', 'Job Description'])
|
91 |
+
st.plotly_chart(fig2, key = "figure 2")
|
92 |
|
93 |
+
st.subheader("Cosine Similarity Scores (Job Description vs. Resumes):")
|
94 |
+
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
95 |
+
st.write(f"Similarity with Candidate Profile {i + 1}: {similarity_score:.4f}")
|
|
|
96 |
|
97 |
else:
|
98 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts})")
|
99 |
+
|
100 |
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
101 |
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
102 |
|
103 |
|
104 |
|
105 |
+
|
106 |
+
|
107 |
+
st.subheader("Candidate Profile 2", divider = "green")
|
108 |
+
|
109 |
+
txt = st.text_area("Job description", key = "text 2")
|
110 |
+
job = pd.Series(txt, name="Text")
|
111 |
if 'upload_count' not in st.session_state:
|
112 |
st.session_state['upload_count'] = 0
|
113 |
+
max_attempts = 2
|
|
|
|
|
114 |
if st.session_state['upload_count'] < max_attempts:
|
115 |
uploaded_files = st.file_uploader(
|
116 |
+
"Upload your resume in .pdf format", type="pdf", key="candidate 2"
|
117 |
)
|
118 |
+
if uploaded_files:
|
119 |
+
st.session_state['upload_count'] += 1
|
120 |
+
for uploaded_file in uploaded_files:
|
121 |
+
pdf_reader = PdfReader(uploaded_file)
|
122 |
+
text_data = ""
|
123 |
+
for page in pdf_reader.pages:
|
124 |
+
text_data += page.extract_text()
|
125 |
+
data = pd.Series(text_data, name = 'Text')
|
126 |
+
frames = [job, data]
|
127 |
+
result = pd.concat(frames)
|
128 |
+
|
129 |
+
|
130 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
131 |
+
labels = ["person", "country","organization", "date", "time", "role", "skills", "year"]
|
132 |
+
entities = model.predict_entities(text_data, labels)
|
133 |
+
df = pd.DataFrame(entities)
|
134 |
+
|
135 |
+
|
136 |
+
fig1 = px.treemap(entities, path=[px.Constant("all"), 'text', 'label'],
|
|
|
|
|
|
|
|
|
137 |
values='score', color='label')
|
138 |
+
fig1.update_layout(margin = dict(t=50, l=25, r=25, b=25))
|
139 |
+
st.plotly_chart(fig1, key = "figure 3")
|
140 |
+
|
141 |
+
vectorizer = TfidfVectorizer()
|
142 |
+
tfidf_matrix = vectorizer.fit_transform(result)
|
143 |
+
tfidf_df = pd.DataFrame(tfidf_matrix.toarray(), columns=vectorizer.get_feature_names_out())
|
144 |
+
cosine_sim_matrix = cosine_similarity(tfidf_matrix)
|
145 |
+
cosine_sim_df = pd.DataFrame(cosine_sim_matrix)
|
146 |
+
|
147 |
+
|
148 |
+
fig2 = px.imshow(cosine_sim_df, text_auto=True, labels=dict(x="Keyword similarity", y="Resumes", color="Productivity"),
|
149 |
+
x=['Resume 1', 'Jon Description'],
|
150 |
+
y=['Resume 1', 'Job Description'])
|
151 |
+
st.plotly_chart(fig2, key = "figure 4")
|
152 |
+
st.subheader("Cosine Similarity Scores (Job Description vs. Resumes):")
|
153 |
+
for i, similarity_score in enumerate(cosine_sim_matrix[0][1:]):
|
154 |
+
st.write(f"Similarity with Candidate Profile {i + 1}: {similarity_score:.4f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
else:
|
156 |
+
st.warning(f"You have reached the maximum upload attempts ({max_attempts})")
|
|
|
157 |
if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
158 |
st.info(f"Files uploaded {st.session_state['upload_count']} time(s).")
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
+
|
164 |
|
165 |
|
166 |
|