Update app.py
Browse files
app.py
CHANGED
@@ -49,7 +49,7 @@ job = pd.Series(txt, name="Text")
|
|
49 |
if 'upload_count' not in st.session_state:
|
50 |
st.session_state['upload_count'] = 0
|
51 |
|
52 |
-
max_attempts =
|
53 |
|
54 |
if st.session_state['upload_count'] < max_attempts:
|
55 |
uploaded_files = st.file_uploader(
|
@@ -94,6 +94,7 @@ if st.session_state['upload_count'] < max_attempts:
|
|
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 |
|
@@ -104,58 +105,8 @@ if 'upload_count' in st.session_state and st.session_state['upload_count'] > 0:
|
|
104 |
|
105 |
|
106 |
|
107 |
-
|
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 |
|
|
|
49 |
if 'upload_count' not in st.session_state:
|
50 |
st.session_state['upload_count'] = 0
|
51 |
|
52 |
+
max_attempts = 3
|
53 |
|
54 |
if st.session_state['upload_count'] < max_attempts:
|
55 |
uploaded_files = st.file_uploader(
|
|
|
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 |
+
|
98 |
else:
|
99 |
st.warning(f"You have reached the maximum upload attempts ({max_attempts})")
|
100 |
|
|
|
105 |
|
106 |
|
107 |
|
108 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
|
112 |
|