Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -82,13 +82,19 @@ def extract_basic_resume_info(text):
|
|
82 |
|
83 |
# Extract Job Experience using the "experience" section.
|
84 |
# Capture everything after the word "experience" until a new section or the end.
|
85 |
-
experience_match = re.search(
|
|
|
|
|
|
|
|
|
86 |
if experience_match:
|
87 |
job_experience = experience_match.group(1).strip()
|
88 |
info["Job Experience"] = " ".join(job_experience.split())
|
89 |
else:
|
90 |
# Fallback if not a labeled section.
|
91 |
-
exp_match = re.search(
|
|
|
|
|
92 |
if exp_match:
|
93 |
info["Job Experience"] = f"{exp_match.group(1)} {exp_match.group(2)}"
|
94 |
|
@@ -99,7 +105,9 @@ def extract_basic_resume_info(text):
|
|
99 |
info["Skills"] = skills_str.rstrip(".")
|
100 |
|
101 |
# Extract Education (e.g., "Education: ...")
|
102 |
-
edu_match = re.search(
|
|
|
|
|
103 |
if edu_match:
|
104 |
education_block = edu_match.group(1).strip()
|
105 |
info["Education"] = " ".join(education_block.split())
|
@@ -158,8 +166,6 @@ def compute_suitability(candidate_summary, company_prompt, model):
|
|
158 |
# Main Resume Processing Logic
|
159 |
#####################################
|
160 |
def process_resume(file_obj):
|
161 |
-
if file_obj is None:
|
162 |
-
return None
|
163 |
resume_text = extract_text_from_file(file_obj)
|
164 |
basic_info = extract_basic_resume_info(resume_text)
|
165 |
summary_paragraph = summarize_basic_info(basic_info)
|
@@ -178,39 +184,56 @@ model = load_model()
|
|
178 |
# Streamlit Interface
|
179 |
#####################################
|
180 |
st.title("Resume Analyzer and Company Suitability Checker")
|
181 |
-
st.markdown(
|
182 |
-
|
183 |
-
|
|
|
184 |
(using a pre-defined prompt for Google LLC) to produce a suitability score.
|
185 |
-
"""
|
|
|
186 |
|
|
|
187 |
uploaded_file = st.file_uploader("Upload Resume", type=["doc", "docx"])
|
188 |
|
|
|
189 |
if st.button("Process Resume"):
|
190 |
if uploaded_file is None:
|
191 |
-
st.error("Please upload a file first.")
|
192 |
else:
|
193 |
with st.spinner("Processing resume..."):
|
194 |
-
|
195 |
-
|
196 |
st.subheader("Candidate Summary")
|
197 |
-
st.markdown(
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
# Extract Job Experience using the "experience" section.
|
84 |
# Capture everything after the word "experience" until a new section or the end.
|
85 |
+
experience_match = re.search(
|
86 |
+
r"experience\s*(.*?)(?:\n\s*\n|additional information|skills|education|$)",
|
87 |
+
text,
|
88 |
+
re.IGNORECASE | re.DOTALL,
|
89 |
+
)
|
90 |
if experience_match:
|
91 |
job_experience = experience_match.group(1).strip()
|
92 |
info["Job Experience"] = " ".join(job_experience.split())
|
93 |
else:
|
94 |
# Fallback if not a labeled section.
|
95 |
+
exp_match = re.search(
|
96 |
+
r"(\d+)\s+(years|yrs)\s+(?:of\s+)?experience", text, re.IGNORECASE
|
97 |
+
)
|
98 |
if exp_match:
|
99 |
info["Job Experience"] = f"{exp_match.group(1)} {exp_match.group(2)}"
|
100 |
|
|
|
105 |
info["Skills"] = skills_str.rstrip(".")
|
106 |
|
107 |
# Extract Education (e.g., "Education: ...")
|
108 |
+
edu_match = re.search(
|
109 |
+
r"education\s*(.*?)(?:\n\s*\n|experience|$)", text, re.IGNORECASE | re.DOTALL
|
110 |
+
)
|
111 |
if edu_match:
|
112 |
education_block = edu_match.group(1).strip()
|
113 |
info["Education"] = " ".join(education_block.split())
|
|
|
166 |
# Main Resume Processing Logic
|
167 |
#####################################
|
168 |
def process_resume(file_obj):
|
|
|
|
|
169 |
resume_text = extract_text_from_file(file_obj)
|
170 |
basic_info = extract_basic_resume_info(resume_text)
|
171 |
summary_paragraph = summarize_basic_info(basic_info)
|
|
|
184 |
# Streamlit Interface
|
185 |
#####################################
|
186 |
st.title("Resume Analyzer and Company Suitability Checker")
|
187 |
+
st.markdown(
|
188 |
+
"""
|
189 |
+
Upload your resume file in **.doc** or **.docx** format. The app extracts key details such as name, age, job experience, skills,
|
190 |
+
and education, and summarizes them into a single paragraph. Then, it compares the candidate summary with a company profile
|
191 |
(using a pre-defined prompt for Google LLC) to produce a suitability score.
|
192 |
+
"""
|
193 |
+
)
|
194 |
|
195 |
+
# File uploader for resume
|
196 |
uploaded_file = st.file_uploader("Upload Resume", type=["doc", "docx"])
|
197 |
|
198 |
+
# Button to process the resume and store the summary in session state.
|
199 |
if st.button("Process Resume"):
|
200 |
if uploaded_file is None:
|
201 |
+
st.error("Please upload a resume file first.")
|
202 |
else:
|
203 |
with st.spinner("Processing resume..."):
|
204 |
+
candidate_summary = process_resume(uploaded_file)
|
205 |
+
st.session_state["candidate_summary"] = candidate_summary
|
206 |
st.subheader("Candidate Summary")
|
207 |
+
st.markdown(candidate_summary)
|
208 |
+
|
209 |
+
# Pre-define the company prompt for Google LLC.
|
210 |
+
default_company_prompt = (
|
211 |
+
"Google LLC, a global leader in technology and innovation, specializes in internet services, cloud computing, "
|
212 |
+
"artificial intelligence, and software development. As part of Alphabet Inc., Google seeks candidates with strong "
|
213 |
+
"problem-solving skills, adaptability, and collaboration abilities. Technical roles require proficiency in programming "
|
214 |
+
"languages such as Python, Java, C++, Go, or JavaScript, with expertise in data structures, algorithms, and system design. "
|
215 |
+
"Additionally, skills in AI, cybersecurity, UX/UI design, and digital marketing are highly valued. Google fosters a culture "
|
216 |
+
"of innovation, expecting candidates to demonstrate creativity, analytical thinking, and a passion for cutting-edge technology."
|
217 |
+
)
|
218 |
+
|
219 |
+
# Company prompt text area.
|
220 |
+
company_prompt = st.text_area(
|
221 |
+
"Enter company details:",
|
222 |
+
value=default_company_prompt,
|
223 |
+
height=150,
|
224 |
+
)
|
225 |
+
|
226 |
+
# Button to compute the suitability score.
|
227 |
+
if st.button("Compute Suitability Score"):
|
228 |
+
if "candidate_summary" not in st.session_state:
|
229 |
+
st.error("Please process the resume first!")
|
230 |
+
else:
|
231 |
+
candidate_summary = st.session_state["candidate_summary"]
|
232 |
+
if candidate_summary.strip() == "":
|
233 |
+
st.error("Candidate summary is empty; please check your resume file.")
|
234 |
+
elif company_prompt.strip() == "":
|
235 |
+
st.error("Please enter the company information.")
|
236 |
+
else:
|
237 |
+
with st.spinner("Computing suitability score..."):
|
238 |
+
score = compute_suitability(candidate_summary, company_prompt, model)
|
239 |
+
st.success(f"Suitability Score: {score:.2f} (range 0 to 1)")
|