import streamlit as st from docx import Document import pdfplumber import re from collections import Counter # Custom CSS for UI enhancements def apply_custom_css(): st.markdown(""" """, unsafe_allow_html=True) # Function to extract text from PDF def extract_text_from_pdf(pdf_file): with pdfplumber.open(pdf_file) as pdf: text = "" for page in pdf.pages: text += page.extract_text() + "\n" return text # Function to extract text from Word Document def extract_text_from_docx(docx_file): doc = Document(docx_file) text = "" for paragraph in doc.paragraphs: text += paragraph.text + "\n" return text # Function to check ATS-friendliness def check_ats_friendly(text): score = 100 suggestions = [] # Keywords check keywords = ["experience", "skills", "education", "certification", "achievements"] for keyword in keywords: if keyword not in text.lower(): score -= 10 suggestions.append(f"Add more emphasis on '{keyword}' in your resume.") # Formatting check if re.search(r"[\t]", text): # Tabs are not ATS-friendly score -= 10 suggestions.append("Avoid using tabs for formatting; use spaces or standard bullet points.") # Font styles check if re.search(r"[{}<>]", text): # Symbols like curly braces and angled brackets can confuse ATS score -= 10 suggestions.append("Remove any special symbols like {}, <>, etc., which might confuse ATS.") # Contact info check if not re.search(r"\b\d{10}\b", text): # Check for a 10-digit phone number score -= 10 suggestions.append("Ensure your resume includes a valid phone number.") if not re.search(r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}", text): # Check for an email score -= 10 suggestions.append("Include a valid professional email address.") # Suggestion for simplicity if len(text.split()) > 1000: # Resume too long score -= 10 suggestions.append("Try to keep your resume concise and limit it to one or two pages.") return score, suggestions # Function to calculate job fit score and recommend missing keywords def calculate_job_fit_score(resume_text, job_description): resume_words = Counter(resume_text.lower().split()) job_words = Counter(job_description.lower().split()) # Find overlap between resume and job description keywords common_words = resume_words & job_words total_job_words = sum(job_words.values()) missing_keywords = set(job_words.keys()) - set(resume_words.keys()) # Calculate match percentage if total_job_words == 0: match_percentage = 0 else: match_percentage = sum(common_words.values()) / total_job_words * 100 suggestions = [] if match_percentage < 100: suggestions.append( "Consider including the missing keywords in your resume to improve matching." ) return match_percentage, suggestions, missing_keywords # Main App def main(): apply_custom_css() st.markdown("