AI_cv_analyzer / model.py
mutaibamohsin845's picture
Create model.py
55c0eec verified
raw
history blame
953 Bytes
import pdfplumber
import spacy
import re
# Load NLP Model
nlp = spacy.load("en_core_web_sm")
# Predefined ATS-friendly keywords
REQUIRED_SKILLS = {"Python", "Machine Learning", "NLP", "Deep Learning", "AI", "Data Science", "Cloud", "Hugging Face"}
def extract_text_from_pdf(pdf_path):
text = ""
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
text += page.extract_text() + "\n"
return text.strip()
def analyze_resume(text):
doc = nlp(text)
# Extract skills and education
words = set([token.text for token in doc if token.is_alpha])
matched_skills = REQUIRED_SKILLS.intersection(words)
missing_skills = REQUIRED_SKILLS - matched_skills
# Basic ATS Check
ats_score = (len(matched_skills) / len(REQUIRED_SKILLS)) * 100
return {
"matched_skills": list(matched_skills),
"missing_skills": list(missing_skills),
"ats_score": round(ats_score, 2)
}