Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -133,40 +133,11 @@ def analyze_sentiment(text):
|
|
133 |
|
134 |
# --- Updated Resume Analysis Function --- #
|
135 |
def analyze_resume(resume_file, job_description_file):
|
|
|
136 |
# Load and preprocess resume and job description
|
137 |
resume_text = extract_text_from_file(resume_file)
|
138 |
job_description_text = extract_text_from_file(job_description_file)
|
139 |
|
140 |
-
# Perform various analyses...
|
141 |
-
skills_similarity = compute_skills_similarity(resume_text, job_description_text)
|
142 |
-
qualifications_similarity = compute_qualifications_similarity(resume_text, job_description_text)
|
143 |
-
experience_similarity = compute_experience_similarity(resume_text, job_description_text)
|
144 |
-
|
145 |
-
# Analyze sentiment for the resume
|
146 |
-
sentiment = analyze_sentiment(resume_text)
|
147 |
-
|
148 |
-
# Summarize experiences
|
149 |
-
resume_experience_summary = summarize_experience(resume_text)
|
150 |
-
job_description_experience_summary = summarize_experience(job_description_text)
|
151 |
-
|
152 |
-
# Extract skills
|
153 |
-
resume_skills = extract_skills(resume_text)
|
154 |
-
job_description_skills = extract_skills(job_description_text)
|
155 |
-
|
156 |
-
response_message = f"After a detailed analysis of the candidate's resume..."
|
157 |
-
|
158 |
-
return (
|
159 |
-
response_message,
|
160 |
-
skills_similarity,
|
161 |
-
qualifications_similarity,
|
162 |
-
experience_similarity,
|
163 |
-
sentiment,
|
164 |
-
resume_experience_summary,
|
165 |
-
job_description_experience_summary,
|
166 |
-
resume_skills,
|
167 |
-
job_description_skills
|
168 |
-
)
|
169 |
-
|
170 |
# Extract skills, qualifications, and experience
|
171 |
resume_skills = extract_skills_llama(resume_text)
|
172 |
job_description_skills = process_job_description(job_description_text)
|
@@ -175,10 +146,6 @@ def analyze_resume(resume_file, job_description_file):
|
|
175 |
resume_experience, resume_job_titles = extract_experience(resume_text)
|
176 |
job_description_experience, job_description_titles = extract_experience(job_description_text)
|
177 |
|
178 |
-
# Summarize experiences
|
179 |
-
resume_experience_summary = summarize_experience(resume_text)
|
180 |
-
job_description_experience_summary = summarize_experience(job_description_text)
|
181 |
-
|
182 |
# Calculate semantic similarity for different sections in percentages
|
183 |
skills_similarity = calculate_semantic_similarity(' '.join(resume_skills), ' '.join(job_description_skills))
|
184 |
qualifications_similarity = calculate_semantic_similarity(' '.join(resume_qualifications), ' '.join(job_description_qualifications))
|
@@ -186,7 +153,6 @@ def analyze_resume(resume_file, job_description_file):
|
|
186 |
|
187 |
# Assuming candidate experience is the total of years from the resume
|
188 |
candidate_experience = sum(resume_experience)
|
189 |
-
required_experience = sum(job_description_experience) # This assumes job description contains required experience as years
|
190 |
|
191 |
# Generate communication based on analysis
|
192 |
response_message = communication_generator(
|
@@ -207,51 +173,35 @@ def analyze_resume(resume_file, job_description_file):
|
|
207 |
"experience_similarity": experience_similarity,
|
208 |
"response_message": response_message,
|
209 |
"sentiment": sentiment,
|
210 |
-
"
|
211 |
-
"job_description_experience_summary": job_description_experience_summary,
|
212 |
-
"resume_skills": resume_skills,
|
213 |
-
"job_description_skills": job_description_skills,
|
214 |
}
|
215 |
|
216 |
# --- Gradio Interface --- #
|
217 |
-
def
|
218 |
-
"""
|
219 |
with gr.Blocks() as demo:
|
220 |
gr.Markdown("# Resume Analyzer")
|
221 |
with gr.Row():
|
222 |
-
|
223 |
-
|
224 |
-
analyze_button = gr.Button("Analyze")
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
inputs=[resume_file, job_description_file],
|
241 |
-
outputs=[
|
242 |
-
output_message,
|
243 |
-
skills_similarity_output,
|
244 |
-
qualifications_similarity_output,
|
245 |
-
experience_similarity_output,
|
246 |
-
sentiment_output,
|
247 |
-
resume_summary_output,
|
248 |
-
job_description_summary_output,
|
249 |
-
resume_skills_output,
|
250 |
-
job_description_skills_output,
|
251 |
-
]
|
252 |
-
)
|
253 |
|
254 |
demo.launch()
|
255 |
|
256 |
-
|
257 |
-
|
|
|
133 |
|
134 |
# --- Updated Resume Analysis Function --- #
|
135 |
def analyze_resume(resume_file, job_description_file):
|
136 |
+
"""Analyzes the resume and job description for skills, qualifications, and experience."""
|
137 |
# Load and preprocess resume and job description
|
138 |
resume_text = extract_text_from_file(resume_file)
|
139 |
job_description_text = extract_text_from_file(job_description_file)
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
# Extract skills, qualifications, and experience
|
142 |
resume_skills = extract_skills_llama(resume_text)
|
143 |
job_description_skills = process_job_description(job_description_text)
|
|
|
146 |
resume_experience, resume_job_titles = extract_experience(resume_text)
|
147 |
job_description_experience, job_description_titles = extract_experience(job_description_text)
|
148 |
|
|
|
|
|
|
|
|
|
149 |
# Calculate semantic similarity for different sections in percentages
|
150 |
skills_similarity = calculate_semantic_similarity(' '.join(resume_skills), ' '.join(job_description_skills))
|
151 |
qualifications_similarity = calculate_semantic_similarity(' '.join(resume_qualifications), ' '.join(job_description_qualifications))
|
|
|
153 |
|
154 |
# Assuming candidate experience is the total of years from the resume
|
155 |
candidate_experience = sum(resume_experience)
|
|
|
156 |
|
157 |
# Generate communication based on analysis
|
158 |
response_message = communication_generator(
|
|
|
173 |
"experience_similarity": experience_similarity,
|
174 |
"response_message": response_message,
|
175 |
"sentiment": sentiment,
|
176 |
+
"candidate_experience": candidate_experience
|
|
|
|
|
|
|
177 |
}
|
178 |
|
179 |
# --- Gradio Interface --- #
|
180 |
+
def run_gradio_interface():
|
181 |
+
"""Runs the Gradio app interface."""
|
182 |
with gr.Blocks() as demo:
|
183 |
gr.Markdown("# Resume Analyzer")
|
184 |
with gr.Row():
|
185 |
+
resume_file_input = gr.File(label="Upload Resume (PDF/TXT)")
|
186 |
+
job_description_file_input = gr.File(label="Upload Job Description (PDF/TXT)")
|
187 |
+
analyze_button = gr.Button("Analyze Resume")
|
188 |
+
|
189 |
+
output_display = gr.Output()
|
190 |
+
|
191 |
+
def analyze_callback(resume_file, job_description_file):
|
192 |
+
analysis_results = analyze_resume(resume_file, job_description_file)
|
193 |
+
return (
|
194 |
+
f"**Skills Similarity**: {analysis_results['skills_similarity']:.2f}%\n"
|
195 |
+
f"**Qualifications Similarity**: {analysis_results['qualifications_similarity']:.2f}%\n"
|
196 |
+
f"**Experience Similarity**: {analysis_results['experience_similarity']:.2f}%\n"
|
197 |
+
f"**Candidate Experience**: {analysis_results['candidate_experience']} years\n"
|
198 |
+
f"**Sentiment**: {analysis_results['sentiment']}\n"
|
199 |
+
f"**Response Message**:\n{analysis_results['response_message']}"
|
200 |
+
)
|
201 |
+
|
202 |
+
analyze_button.click(analyze_callback, inputs=[resume_file_input, job_description_file_input], outputs=output_display)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
|
204 |
demo.launch()
|
205 |
|
206 |
+
if __name__ == "__main__":
|
207 |
+
run_gradio_interface()
|