Spaces:
Sleeping
Sleeping
DreamStream-1
commited on
Update app.py
Browse files
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 |
-
# ---
|
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
|
177 |
-
"""
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
gr.
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|