Spaces:
Build error
Build error
File size: 3,698 Bytes
5dd50e1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
import streamlit as st
import PyPDF2
import re
# Function to extract text from a PDF
def extract_text_from_pdf(uploaded_file):
pdf_reader = PyPDF2.PdfReader(uploaded_file)
text = " ".join([page.extract_text() for page in pdf_reader.pages if page.extract_text()])
return text
# Function to extract skills from text (reference resumes and user resumes)
def extract_skills_from_text(text):
# A simple way to extract skills based on words in the resume.
# This can be more advanced by integrating NER (Named Entity Recognition) or using predefined skill lists.
skills = re.findall(r'\b[A-Za-z]+\b', text.lower()) # Extract words
skills = set(skills) # Remove duplicates
return skills
# Function to evaluate user's resume based on job description
def evaluate_resume(candidate_text, job_description_text):
# Extract skills dynamically from job description
job_description_skills = extract_skills_from_text(job_description_text)
# Extract skills from candidate's resume
candidate_skills = extract_skills_from_text(candidate_text)
# Calculate matching skills
matching_skills = job_description_skills.intersection(candidate_skills)
missing_skills = job_description_skills.difference(candidate_skills)
# Calculate improvement skills (skills present in the JD but not in candidate's resume)
improvement_skills = job_description_skills.difference(matching_skills)
# Calculate matching percentage (based on skills)
matching_percentage = (len(matching_skills) / len(job_description_skills)) * 100 if len(job_description_skills) > 0 else 0
result = {
"matching_skills": list(matching_skills),
"missing_skills": list(missing_skills),
"improvement_skills": list(improvement_skills),
"matching_percentage": round(matching_percentage, 2)
}
return result
# Streamlit UI
st.title("π Resume Screening with Job Description Matching")
st.write("Upload a candidate's resume and provide a job description to check the matching percentage based on skills.")
# Upload job description
st.subheader("Upload Job Description")
job_description_file = st.file_uploader("Upload Job Description (PDF)", type=["pdf"])
# Upload candidate resume
st.subheader("Upload Candidate Resume")
uploaded_file = st.file_uploader("Upload Candidate Resume (PDF)", type=["pdf"])
if uploaded_file and job_description_file:
st.write("π **Processing resume and job description...**")
# Extract text from candidate resume
candidate_text = extract_text_from_pdf(uploaded_file)
# Extract text from job description
job_description_text = extract_text_from_pdf(job_description_file)
# Evaluate resume based on job description
evaluation = evaluate_resume(candidate_text, job_description_text)
# Display results
st.subheader("π Evaluation Result:")
st.write(f"**π’ Matching Percentage:** {evaluation['matching_percentage']}%")
# st.write(f"**β
Matching Skills:** {', '.join(evaluation['matching_skills']) or 'None'}")
# st.write(f"**β Missing Skills:** {', '.join(evaluation['missing_skills']) or 'None'}")
st.write(f"**π‘ Improvement Skills (Required but Missing):** {', '.join(evaluation['improvement_skills']) or 'None'}")
if evaluation["matching_percentage"] > 70:
st.success("β
Resume is a strong match for the job description!")
elif evaluation["matching_percentage"] > 40:
st.warning("β οΈ Resume is a partial match for the job description.")
else:
st.error("β Resume does not match well with the job description.")
else:
st.write("Please upload both the job description and candidate resume.")
|