Spaces:
Sleeping
Sleeping
Update model.py
Browse files
model.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import pdfplumber
|
| 2 |
import spacy
|
| 3 |
-
import re
|
| 4 |
|
| 5 |
# Load NLP Model
|
| 6 |
nlp = spacy.load("en_core_web_sm")
|
|
@@ -9,6 +8,7 @@ nlp = spacy.load("en_core_web_sm")
|
|
| 9 |
REQUIRED_SKILLS = {"Python", "Machine Learning", "NLP", "Deep Learning", "AI", "Data Science", "Cloud", "Hugging Face"}
|
| 10 |
|
| 11 |
def extract_text_from_pdf(pdf_path):
|
|
|
|
| 12 |
text = ""
|
| 13 |
with pdfplumber.open(pdf_path) as pdf:
|
| 14 |
for page in pdf.pages:
|
|
@@ -16,14 +16,15 @@ def extract_text_from_pdf(pdf_path):
|
|
| 16 |
return text.strip()
|
| 17 |
|
| 18 |
def analyze_resume(text):
|
|
|
|
| 19 |
doc = nlp(text)
|
| 20 |
|
| 21 |
-
# Extract skills
|
| 22 |
words = set([token.text for token in doc if token.is_alpha])
|
| 23 |
matched_skills = REQUIRED_SKILLS.intersection(words)
|
| 24 |
missing_skills = REQUIRED_SKILLS - matched_skills
|
| 25 |
|
| 26 |
-
#
|
| 27 |
ats_score = (len(matched_skills) / len(REQUIRED_SKILLS)) * 100
|
| 28 |
|
| 29 |
return {
|
|
|
|
| 1 |
import pdfplumber
|
| 2 |
import spacy
|
|
|
|
| 3 |
|
| 4 |
# Load NLP Model
|
| 5 |
nlp = spacy.load("en_core_web_sm")
|
|
|
|
| 8 |
REQUIRED_SKILLS = {"Python", "Machine Learning", "NLP", "Deep Learning", "AI", "Data Science", "Cloud", "Hugging Face"}
|
| 9 |
|
| 10 |
def extract_text_from_pdf(pdf_path):
|
| 11 |
+
"""Extract text from a resume PDF"""
|
| 12 |
text = ""
|
| 13 |
with pdfplumber.open(pdf_path) as pdf:
|
| 14 |
for page in pdf.pages:
|
|
|
|
| 16 |
return text.strip()
|
| 17 |
|
| 18 |
def analyze_resume(text):
|
| 19 |
+
"""Analyze the resume text and provide ATS recommendations"""
|
| 20 |
doc = nlp(text)
|
| 21 |
|
| 22 |
+
# Extract skills
|
| 23 |
words = set([token.text for token in doc if token.is_alpha])
|
| 24 |
matched_skills = REQUIRED_SKILLS.intersection(words)
|
| 25 |
missing_skills = REQUIRED_SKILLS - matched_skills
|
| 26 |
|
| 27 |
+
# Calculate ATS Score
|
| 28 |
ats_score = (len(matched_skills) / len(REQUIRED_SKILLS)) * 100
|
| 29 |
|
| 30 |
return {
|