DreamStream-1 commited on
Commit
8e10984
1 Parent(s): ff32b52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -33
app.py CHANGED
@@ -90,16 +90,6 @@ def calculate_semantic_similarity(text1, text2):
90
  similarity_percentage = similarity_score * 100
91
  return similarity_percentage
92
 
93
- # --- Thresholds --- #
94
- def categorize_similarity(score):
95
- """Categorizes the similarity score into thresholds for better insights."""
96
- if score >= 80:
97
- return "High Match"
98
- elif score >= 50:
99
- return "Moderate Match"
100
- else:
101
- return "Low Match"
102
-
103
  # --- Communication Generation with Enhanced Response --- #
104
  def communication_generator(resume_skills, job_description_skills, skills_similarity, qualifications_similarity, experience_similarity, candidate_experience):
105
  """Generates a detailed communication response based on similarity scores and additional criteria."""
@@ -170,40 +160,72 @@ def analyze_resume(resume_file, job_description_file):
170
 
171
  # Assuming candidate experience is the total of years from the resume
172
  candidate_experience = sum(resume_experience)
 
173
 
174
  # Generate communication based on analysis
175
  response_message = communication_generator(
176
- resume_skills, job_description_skills,
177
- skills_similarity, qualifications_similarity,
178
- experience_similarity, candidate_experience
 
 
 
179
  )
180
 
181
- # Perform sentiment analysis on the resume
182
- sentiment_analysis_result = analyze_sentiment(resume_text)
183
 
184
  return {
185
  "skills_similarity": skills_similarity,
186
  "qualifications_similarity": qualifications_similarity,
187
  "experience_similarity": experience_similarity,
 
 
188
  "resume_experience_summary": resume_experience_summary,
189
  "job_description_experience_summary": job_description_experience_summary,
190
- "response_message": response_message,
191
- "sentiment": sentiment_analysis_result,
192
  }
193
 
194
- # --- Gradio Interface Setup --- #
195
- def upload_and_analyze(resume_file, job_description_file):
196
- """Handles file upload and calls the analysis function."""
197
- return analyze_resume(resume_file, job_description_file)
198
-
199
- # Create a Gradio interface for the application
200
- interface = gr.Interface(
201
- fn=upload_and_analyze,
202
- inputs=["file", "file"],
203
- outputs=["json"],
204
- title="Resume and Job Description Analyzer",
205
- description="Upload a resume and a job description to analyze the fit.",
206
- )
207
-
208
- # Run the Gradio interface
209
- interface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  similarity_percentage = similarity_score * 100
91
  return similarity_percentage
92
 
 
 
 
 
 
 
 
 
 
 
93
  # --- Communication Generation with Enhanced Response --- #
94
  def communication_generator(resume_skills, job_description_skills, skills_similarity, qualifications_similarity, experience_similarity, candidate_experience):
95
  """Generates a detailed communication response based on similarity scores and additional criteria."""
 
160
 
161
  # Assuming candidate experience is the total of years from the resume
162
  candidate_experience = sum(resume_experience)
163
+ required_experience = sum(job_description_experience) # This assumes job description contains required experience as years
164
 
165
  # Generate communication based on analysis
166
  response_message = communication_generator(
167
+ resume_skills,
168
+ job_description_skills,
169
+ skills_similarity,
170
+ qualifications_similarity,
171
+ experience_similarity,
172
+ candidate_experience
173
  )
174
 
175
+ # Analyze sentiment for the resume
176
+ sentiment = analyze_sentiment(resume_text)
177
 
178
  return {
179
  "skills_similarity": skills_similarity,
180
  "qualifications_similarity": qualifications_similarity,
181
  "experience_similarity": experience_similarity,
182
+ "response_message": response_message,
183
+ "sentiment": sentiment,
184
  "resume_experience_summary": resume_experience_summary,
185
  "job_description_experience_summary": job_description_experience_summary,
186
+ "resume_skills": resume_skills,
187
+ "job_description_skills": job_description_skills,
188
  }
189
 
190
+ # --- Gradio Interface --- #
191
+ def gradio_interface():
192
+ """Defines and runs the Gradio interface."""
193
+ with gr.Blocks() as demo:
194
+ gr.Markdown("# Resume Analyzer")
195
+ with gr.Row():
196
+ resume_file = gr.File(label="Upload Resume (PDF/TXT)")
197
+ job_description_file = gr.File(label="Upload Job Description (PDF/TXT)")
198
+ analyze_button = gr.Button("Analyze")
199
+
200
+ with gr.Tab("Results"):
201
+ output_message = gr.Textbox(label="Analysis Message", lines=10)
202
+ skills_similarity_output = gr.Number(label="Skills Similarity (%)")
203
+ qualifications_similarity_output = gr.Number(label="Qualifications Similarity (%)")
204
+ experience_similarity_output = gr.Number(label="Experience Similarity (%)")
205
+ sentiment_output = gr.Textbox(label="Sentiment Analysis")
206
+ resume_summary_output = gr.Textbox(label="Resume Experience Summary", lines=5)
207
+ job_description_summary_output = gr.Textbox(label="Job Description Experience Summary", lines=5)
208
+ resume_skills_output = gr.Textbox(label="Resume Skills", lines=5)
209
+ job_description_skills_output = gr.Textbox(label="Job Description Skills", lines=5)
210
+
211
+ # Link the button to the analysis function
212
+ analyze_button.click(
213
+ analyze_resume,
214
+ inputs=[resume_file, job_description_file],
215
+ outputs=[
216
+ output_message,
217
+ skills_similarity_output,
218
+ qualifications_similarity_output,
219
+ experience_similarity_output,
220
+ sentiment_output,
221
+ resume_summary_output,
222
+ job_description_summary_output,
223
+ resume_skills_output,
224
+ job_description_skills_output,
225
+ ]
226
+ )
227
+
228
+ demo.launch()
229
+
230
+ # Execute the Gradio interface
231
+ gradio_interface()