DreamStream-1 commited on
Commit
d572e10
·
verified ·
1 Parent(s): 0d8d95c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -16
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import os
2
  import re
3
  from datetime import datetime
 
4
  import torch
5
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForSeq2SeqLM
6
  from sentence_transformers import SentenceTransformer, util
@@ -50,7 +51,6 @@ def extract_skills_llama(text):
50
  # --- Qualification and Experience Extraction --- #
51
  def extract_qualifications(text):
52
  """Extracts qualifications from text (e.g., degrees, certifications)."""
53
- # Simplified logic to extract qualifications (can be improved)
54
  qualifications = re.findall(r'(bachelor|master|phd|certified|degree)', text, re.IGNORECASE)
55
  return qualifications if qualifications else ['No specific qualifications found']
56
 
@@ -61,7 +61,7 @@ def extract_experience(text):
61
  experience_years = [int(year[0]) for year in experience_years]
62
  return experience_years, job_titles
63
 
64
- # --- Matching Function using Semantic Similarity --- #
65
  def calculate_semantic_similarity(text1, text2):
66
  """Calculates semantic similarity using a sentence transformer model and returns the score as a percentage."""
67
  model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
@@ -173,17 +173,29 @@ def analyze_resume(resume_file, job_description_file):
173
  )
174
 
175
  # --- Gradio Interface --- #
176
- def process_job_description(job_description_text):
177
- """Simplified job description processing for skills (can be extended)."""
178
- return re.findall(r'\b(Python|AWS|Machine Learning|Deep Learning|NLP|Docker|Kubernetes)\b', job_description_text, re.IGNORECASE)
179
-
180
- def gradio_app(resume_file, job_description_file):
181
- return analyze_resume(resume_file, job_description_file)
182
-
183
- # --- Launch Gradio App --- #
184
- gr.Interface(fn=gradio_app,
185
- inputs=["file", "file"],
186
- outputs="text",
187
- title="Resume and Job Description Matching Tool",
188
- description="Upload a resume and a job description to assess the matching scores for skills, qualifications, and experience."
189
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import re
3
  from datetime import datetime
4
+ import PyPDF2
5
  import torch
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModelForSeq2SeqLM
7
  from sentence_transformers import SentenceTransformer, util
 
51
  # --- Qualification and Experience Extraction --- #
52
  def extract_qualifications(text):
53
  """Extracts qualifications from text (e.g., degrees, certifications)."""
 
54
  qualifications = re.findall(r'(bachelor|master|phd|certified|degree)', text, re.IGNORECASE)
55
  return qualifications if qualifications else ['No specific qualifications found']
56
 
 
61
  experience_years = [int(year[0]) for year in experience_years]
62
  return experience_years, job_titles
63
 
64
+ # --- Semantic Similarity Calculation --- #
65
  def calculate_semantic_similarity(text1, text2):
66
  """Calculates semantic similarity using a sentence transformer model and returns the score as a percentage."""
67
  model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
 
173
  )
174
 
175
  # --- Gradio Interface --- #
176
+ def main():
177
+ """Runs the Gradio application for resume analysis."""
178
+ interface = gr.Interface(
179
+ fn=analyze_resume,
180
+ inputs=[gr.File(label="Upload Resume (PDF/TXT)"), gr.File(label="Upload Job Description (PDF/TXT)")],
181
+ outputs=[
182
+ gr.Textbox(label="Skills Similarity"),
183
+ gr.Textbox(label="Qualifications Similarity"),
184
+ gr.Textbox(label="Experience Similarity"),
185
+ gr.Textbox(label="Communication Response"),
186
+ gr.Textbox(label="Sentiment Analysis"),
187
+ gr.Textbox(label="Resume Skills"),
188
+ gr.Textbox(label="Job Description Skills"),
189
+ gr.Textbox(label="Resume Qualifications"),
190
+ gr.Textbox(label="Job Description Qualifications"),
191
+ gr.Textbox(label="Resume Experience"),
192
+ gr.Textbox(label="Job Description Experience")
193
+ ],
194
+ title="Resume and Job Description Analysis",
195
+ description="Analyze a resume against a job description to evaluate skills, qualifications, experience, and generate communication insights."
196
+ )
197
+
198
+ interface.launch()
199
+
200
+ if __name__ == "__main__":
201
+ main()