DreamStream-1 commited on
Commit
c28a311
·
verified ·
1 Parent(s): 3e26ed6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -8
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import re
 
2
  import streamlit as st
3
  import requests
4
  from PyPDF2 import PdfReader
@@ -114,6 +115,8 @@ job_description = st.text_area("Job Description:", height=200, placeholder="Past
114
  # Resume Upload
115
  resumes = st.file_uploader("Upload Your Resumes (PDF or DOCX)", type=["pdf", "docx"], accept_multiple_files=True)
116
 
 
 
117
  if resumes:
118
  st.write("Uploaded Resumes:")
119
  for index, resume in enumerate(resumes):
@@ -135,22 +138,51 @@ if st.button("Analyze Resumes"):
135
  contact_info = extract_contact_info(resume_text)
136
  analysis = analyze_documents(resume_text, job_description)
137
 
138
- # Display Contact Info and Match Percentage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  st.markdown(f"""
140
  <div class="highlight">
141
  <p><span class="highlight-bold">Name:</span> {contact_info['name']}</p>
142
  <p><span class="highlight-bold">Email:</span> {contact_info['email']}</p>
143
  <p><span class="highlight-bold">Contact:</span> {contact_info['phone']}</p>
 
144
  </div>
145
  """, unsafe_allow_html=True)
146
 
147
- # Display analysis results
148
- if "candidates" in analysis:
149
- for candidate in analysis["candidates"]:
150
- if "content" in candidate and "parts" in candidate["content"]:
151
- for part in candidate["content"]["parts"]:
152
- response_text = part["text"]
153
- st.markdown(response_text)
 
 
 
 
 
 
 
 
 
154
  else:
155
  st.error("You can upload a maximum of 10 resumes.")
156
  else:
 
1
  import re
2
+ import pandas as pd
3
  import streamlit as st
4
  import requests
5
  from PyPDF2 import PdfReader
 
115
  # Resume Upload
116
  resumes = st.file_uploader("Upload Your Resumes (PDF or DOCX)", type=["pdf", "docx"], accept_multiple_files=True)
117
 
118
+ highlighted_data = [] # List to store the highlighted results
119
+
120
  if resumes:
121
  st.write("Uploaded Resumes:")
122
  for index, resume in enumerate(resumes):
 
138
  contact_info = extract_contact_info(resume_text)
139
  analysis = analyze_documents(resume_text, job_description)
140
 
141
+ # Extract match percentage
142
+ match_percentage = "Not Found"
143
+ if "candidates" in analysis:
144
+ for candidate in analysis["candidates"]:
145
+ if "content" in candidate and "parts" in candidate["content"]:
146
+ for part in candidate["content"]["parts"]:
147
+ response_text = part["text"]
148
+ if "match percentage" in response_text.lower():
149
+ match_percentage = re.search(r'\d{1,3}%', response_text)
150
+ match_percentage = match_percentage.group(0) if match_percentage else "Not Found"
151
+
152
+ # Add the data to the list for CSV export and table
153
+ highlighted_data.append({
154
+ "Name": contact_info["name"],
155
+ "Email": contact_info["email"],
156
+ "Contact": contact_info["phone"],
157
+ "Match Percentage": match_percentage
158
+ })
159
+
160
+ # Display contact info and match percentage
161
  st.markdown(f"""
162
  <div class="highlight">
163
  <p><span class="highlight-bold">Name:</span> {contact_info['name']}</p>
164
  <p><span class="highlight-bold">Email:</span> {contact_info['email']}</p>
165
  <p><span class="highlight-bold">Contact:</span> {contact_info['phone']}</p>
166
+ <p><span class="highlight-bold">Match Percentage:</span> <span style="color: green; font-weight: bold;">{match_percentage}</span></p>
167
  </div>
168
  """, unsafe_allow_html=True)
169
 
170
+ # Display results in a table
171
+ if highlighted_data:
172
+ df = pd.DataFrame(highlighted_data)
173
+ st.write("### Highlighted Results")
174
+ st.table(df)
175
+
176
+ # Provide CSV download button
177
+ csv = df.to_csv(index=False)
178
+ st.download_button(
179
+ label="Download Results as CSV",
180
+ data=csv,
181
+ file_name="resume_analysis_results.csv",
182
+ mime="text/csv"
183
+ )
184
+
185
+ st.success("Analysis Complete!")
186
  else:
187
  st.error("You can upload a maximum of 10 resumes.")
188
  else: