Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -575,91 +575,17 @@ def summarize_resume_text(resume_text, models):
|
|
575 |
job_position = extract_job_position(resume_text)
|
576 |
skills = extract_skills(resume_text)
|
577 |
|
578 |
-
# Extract work experience section
|
579 |
-
work_experience_text = extract_work_experience_section(resume_text)
|
580 |
-
|
581 |
-
# Use the summarization model to summarize the work experience
|
582 |
-
if work_experience_text:
|
583 |
-
# Summarize work experience using the model
|
584 |
-
work_summary = summarize_text(work_experience_text, models, max_length=150)
|
585 |
-
else:
|
586 |
-
work_summary = "No detailed work experience found in the resume."
|
587 |
-
|
588 |
# Format the structured summary with different paragraphs for each critical piece
|
589 |
formatted_summary = f"Name: {name}\n\n"
|
590 |
formatted_summary += f"Age: {age}\n\n"
|
591 |
formatted_summary += f"Expected Industry: {industry}\n\n"
|
592 |
formatted_summary += f"Expected Job Position: {job_position}\n\n"
|
593 |
formatted_summary += f"Skills: {', '.join(skills)}\n\n"
|
594 |
-
|
595 |
-
|
596 |
execution_time = time.time() - start_time
|
597 |
|
598 |
return formatted_summary, execution_time
|
599 |
|
600 |
-
# Extract work experience section
|
601 |
-
def extract_work_experience_section(text):
|
602 |
-
"""Extract work experience section from resume for summarization"""
|
603 |
-
# Work experience extraction
|
604 |
-
work_headers = [
|
605 |
-
"work experience", "professional experience", "employment history",
|
606 |
-
"work history", "experience"
|
607 |
-
]
|
608 |
-
|
609 |
-
next_section_headers = [
|
610 |
-
"education", "skills", "certifications", "projects", "achievements"
|
611 |
-
]
|
612 |
-
|
613 |
-
# Process everything at once
|
614 |
-
lines = text.split('\n')
|
615 |
-
text_lower = text.lower()
|
616 |
-
|
617 |
-
# Work experience extraction
|
618 |
-
work_section = []
|
619 |
-
in_work_section = False
|
620 |
-
|
621 |
-
for idx, line in enumerate(lines):
|
622 |
-
line_lower = line.lower().strip()
|
623 |
-
|
624 |
-
# Start of work section
|
625 |
-
if not in_work_section:
|
626 |
-
if any(header in line_lower for header in work_headers):
|
627 |
-
in_work_section = True
|
628 |
-
continue
|
629 |
-
# End of work section
|
630 |
-
elif in_work_section:
|
631 |
-
if any(header in line_lower for header in next_section_headers):
|
632 |
-
break
|
633 |
-
|
634 |
-
if line.strip():
|
635 |
-
work_section.append(line.strip())
|
636 |
-
|
637 |
-
# If we found a work section, join it back into text for summarization
|
638 |
-
if work_section:
|
639 |
-
return "\n".join(work_section)
|
640 |
-
|
641 |
-
# If no explicit work section found, try to extract paragraphs that might contain work experience
|
642 |
-
# Look for company names, dates, job titles
|
643 |
-
work_related_paragraphs = []
|
644 |
-
paragraphs = text.split('\n\n')
|
645 |
-
|
646 |
-
for paragraph in paragraphs:
|
647 |
-
# Check if paragraph has dates that look like work experience
|
648 |
-
if re.search(r'(19|20)\d{2}\s*-\s*(19|20)\d{2}|present|current', paragraph, re.IGNORECASE):
|
649 |
-
work_related_paragraphs.append(paragraph)
|
650 |
-
# Check for common job titles
|
651 |
-
elif re.search(r'\b(engineer|developer|manager|analyst|director|consultant|specialist)\b',
|
652 |
-
paragraph, re.IGNORECASE):
|
653 |
-
work_related_paragraphs.append(paragraph)
|
654 |
-
# Check for company indicators
|
655 |
-
elif re.search(r'\b(company|corporation|inc\.|corp\.|ltd\.)\b', paragraph, re.IGNORECASE):
|
656 |
-
work_related_paragraphs.append(paragraph)
|
657 |
-
|
658 |
-
if work_related_paragraphs:
|
659 |
-
return "\n\n".join(work_related_paragraphs)
|
660 |
-
|
661 |
-
return "" # Return empty string if no work experience found
|
662 |
-
|
663 |
#####################################
|
664 |
# Function: Extract Job Requirements
|
665 |
#####################################
|
|
|
575 |
job_position = extract_job_position(resume_text)
|
576 |
skills = extract_skills(resume_text)
|
577 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
578 |
# Format the structured summary with different paragraphs for each critical piece
|
579 |
formatted_summary = f"Name: {name}\n\n"
|
580 |
formatted_summary += f"Age: {age}\n\n"
|
581 |
formatted_summary += f"Expected Industry: {industry}\n\n"
|
582 |
formatted_summary += f"Expected Job Position: {job_position}\n\n"
|
583 |
formatted_summary += f"Skills: {', '.join(skills)}\n\n"
|
584 |
+
|
|
|
585 |
execution_time = time.time() - start_time
|
586 |
|
587 |
return formatted_summary, execution_time
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
#####################################
|
590 |
# Function: Extract Job Requirements
|
591 |
#####################################
|