SamiKhokhar commited on
Commit
460bfbf
·
verified ·
1 Parent(s): fcf3762

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -18
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  from docx import Document
3
  import pdfplumber
4
  import re
 
5
 
6
  # Function to extract text from PDF
7
  def extract_text_from_pdf(pdf_file):
@@ -56,43 +57,87 @@ def check_ats_friendly(text):
56
 
57
  return score, suggestions
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  # Main App
60
  def main():
61
- st.title("ATS Resume Checker")
62
- st.write("Upload your resume to check if it is ATS-friendly and get suggestions for improvement.")
 
 
 
 
 
 
 
63
 
64
- uploaded_file = st.file_uploader("Upload your Resume (PDF or Word):", type=["pdf", "docx"])
65
- if uploaded_file:
66
  # Extract text based on file type
67
- if uploaded_file.name.endswith(".pdf"):
68
- resume_text = extract_text_from_pdf(uploaded_file)
69
- elif uploaded_file.name.endswith(".docx"):
70
- resume_text = extract_text_from_docx(uploaded_file)
71
  else:
72
  st.error("Unsupported file format. Please upload a PDF or Word document.")
73
  return
74
 
75
- # Display extracted text (optional)
76
- st.subheader("Extracted Text:")
77
- st.text_area("Resume Content", value=resume_text, height=200)
78
-
79
  # Analyze ATS-friendliness
80
  st.subheader("ATS Analysis")
81
- ats_score, suggestions = check_ats_friendly(resume_text)
82
-
83
  st.metric("ATS Score", f"{ats_score}/100")
84
  if ats_score >= 80:
85
  st.success("Your resume is ATS-friendly!")
86
  else:
87
  st.warning("Your resume needs improvement to be ATS-friendly.")
88
 
89
- # Suggestions
90
- st.subheader("Suggestions for Improvement")
91
- if suggestions:
92
- for idx, suggestion in enumerate(suggestions, 1):
93
  st.write(f"{idx}. {suggestion}")
94
  else:
95
  st.write("No specific suggestions. Your resume looks great!")
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  if __name__ == "__main__":
98
  main()
 
2
  from docx import Document
3
  import pdfplumber
4
  import re
5
+ from collections import Counter
6
 
7
  # Function to extract text from PDF
8
  def extract_text_from_pdf(pdf_file):
 
57
 
58
  return score, suggestions
59
 
60
+ # Function to calculate job fit score
61
+ def calculate_job_fit_score(resume_text, job_description):
62
+ resume_words = Counter(resume_text.lower().split())
63
+ job_words = Counter(job_description.lower().split())
64
+
65
+ # Find overlap between resume and job description keywords
66
+ common_words = resume_words & job_words
67
+ total_job_words = sum(job_words.values())
68
+
69
+ # Calculate match percentage
70
+ if total_job_words == 0:
71
+ match_percentage = 0
72
+ else:
73
+ match_percentage = sum(common_words.values()) / total_job_words * 100
74
+
75
+ suggestions = []
76
+ if match_percentage < 70:
77
+ suggestions.append(
78
+ "Include more relevant keywords from the job description in your resume."
79
+ )
80
+
81
+ return match_percentage, suggestions
82
+
83
  # Main App
84
  def main():
85
+ st.title("ATS Resume Checker with Job Description Matching")
86
+ st.write(
87
+ "Upload your resume to check its ATS-friendliness and compare it with a job description for keyword matching."
88
+ )
89
+
90
+ uploaded_resume = st.file_uploader(
91
+ "Upload your Resume (PDF or Word):", type=["pdf", "docx"]
92
+ )
93
+ job_description = st.text_area("Paste the Job Description:")
94
 
95
+ if uploaded_resume:
 
96
  # Extract text based on file type
97
+ if uploaded_resume.name.endswith(".pdf"):
98
+ resume_text = extract_text_from_pdf(uploaded_resume)
99
+ elif uploaded_resume.name.endswith(".docx"):
100
+ resume_text = extract_text_from_docx(uploaded_resume)
101
  else:
102
  st.error("Unsupported file format. Please upload a PDF or Word document.")
103
  return
104
 
 
 
 
 
105
  # Analyze ATS-friendliness
106
  st.subheader("ATS Analysis")
107
+ ats_score, ats_suggestions = check_ats_friendly(resume_text)
 
108
  st.metric("ATS Score", f"{ats_score}/100")
109
  if ats_score >= 80:
110
  st.success("Your resume is ATS-friendly!")
111
  else:
112
  st.warning("Your resume needs improvement to be ATS-friendly.")
113
 
114
+ # Display ATS suggestions
115
+ st.subheader("Suggestions for ATS Improvement")
116
+ if ats_suggestions:
117
+ for idx, suggestion in enumerate(ats_suggestions, 1):
118
  st.write(f"{idx}. {suggestion}")
119
  else:
120
  st.write("No specific suggestions. Your resume looks great!")
121
 
122
+ # Analyze Job Fit
123
+ if job_description.strip():
124
+ st.subheader("Job Description Matching")
125
+ job_fit_score, job_fit_suggestions = calculate_job_fit_score(
126
+ resume_text, job_description
127
+ )
128
+ st.metric("Job Fit Score", f"{job_fit_score:.2f}%")
129
+ if job_fit_score >= 70:
130
+ st.success("Your resume matches well with the job description!")
131
+ else:
132
+ st.warning("Your resume could be tailored better to match the job description.")
133
+
134
+ # Display job fit suggestions
135
+ st.subheader("Suggestions for Job Matching Improvement")
136
+ if job_fit_suggestions:
137
+ for idx, suggestion in enumerate(job_fit_suggestions, 1):
138
+ st.write(f"{idx}. {suggestion}")
139
+ else:
140
+ st.write("No specific suggestions. Great match!")
141
+
142
  if __name__ == "__main__":
143
  main()