Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -575,8 +575,8 @@ def summarize_resume_text(resume_text, models):
|
|
575 |
job_position = extract_job_position(resume_text)
|
576 |
skills = extract_skills(resume_text)
|
577 |
|
578 |
-
#
|
579 |
-
|
580 |
|
581 |
# Format the structured summary with different paragraphs for each critical piece
|
582 |
formatted_summary = f"Name: {name}\n\n"
|
@@ -584,12 +584,93 @@ def summarize_resume_text(resume_text, models):
|
|
584 |
formatted_summary += f"Expected Industry: {industry}\n\n"
|
585 |
formatted_summary += f"Expected Job Position: {job_position}\n\n"
|
586 |
formatted_summary += f"Skills: {', '.join(skills)}\n\n"
|
587 |
-
formatted_summary += f"
|
588 |
|
589 |
execution_time = time.time() - start_time
|
590 |
|
591 |
return formatted_summary, execution_time
|
592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
#####################################
|
594 |
# Function: Extract Job Requirements
|
595 |
#####################################
|
|
|
575 |
job_position = extract_job_position(resume_text)
|
576 |
skills = extract_skills(resume_text)
|
577 |
|
578 |
+
# Extract work experience
|
579 |
+
work_experience = extract_work_experience(resume_text)
|
580 |
|
581 |
# Format the structured summary with different paragraphs for each critical piece
|
582 |
formatted_summary = f"Name: {name}\n\n"
|
|
|
584 |
formatted_summary += f"Expected Industry: {industry}\n\n"
|
585 |
formatted_summary += f"Expected Job Position: {job_position}\n\n"
|
586 |
formatted_summary += f"Skills: {', '.join(skills)}\n\n"
|
587 |
+
formatted_summary += f"Previous Work Experience: {work_experience}"
|
588 |
|
589 |
execution_time = time.time() - start_time
|
590 |
|
591 |
return formatted_summary, execution_time
|
592 |
|
593 |
+
# Extract work experience
|
594 |
+
def extract_work_experience(text):
|
595 |
+
"""Extract work experience from resume text"""
|
596 |
+
# Work experience extraction
|
597 |
+
work_headers = [
|
598 |
+
"work experience", "professional experience", "employment history",
|
599 |
+
"work history", "experience"
|
600 |
+
]
|
601 |
+
|
602 |
+
next_section_headers = [
|
603 |
+
"education", "skills", "certifications", "projects", "achievements"
|
604 |
+
]
|
605 |
+
|
606 |
+
# Process everything at once
|
607 |
+
lines = text.split('\n')
|
608 |
+
text_lower = text.lower()
|
609 |
+
|
610 |
+
# Work experience extraction - simplified approach
|
611 |
+
work_section = []
|
612 |
+
in_work_section = False
|
613 |
+
|
614 |
+
for idx, line in enumerate(lines):
|
615 |
+
line_lower = line.lower().strip()
|
616 |
+
|
617 |
+
# Start of work section
|
618 |
+
if not in_work_section:
|
619 |
+
if any(header in line_lower for header in work_headers):
|
620 |
+
in_work_section = True
|
621 |
+
continue
|
622 |
+
# End of work section
|
623 |
+
elif in_work_section:
|
624 |
+
if any(header in line_lower for header in next_section_headers):
|
625 |
+
break
|
626 |
+
|
627 |
+
if line.strip():
|
628 |
+
work_section.append(line.strip())
|
629 |
+
|
630 |
+
# Simplified work formatting
|
631 |
+
if not work_section:
|
632 |
+
# If no explicit work section found, try to extract key employment information
|
633 |
+
experience_found = False
|
634 |
+
company_patterns = [
|
635 |
+
r'(\d{4}(?:\s*-\s*\d{4}|\s*-\s*present|\s*-\s*current))\s*([^,.\n]+)',
|
636 |
+
r'(?:at|with|for)\s+([A-Z][A-Za-z\s]+)(?:\s*|\.|,|\()'
|
637 |
+
]
|
638 |
+
|
639 |
+
experience_lines = []
|
640 |
+
for pattern in company_patterns:
|
641 |
+
matches = re.findall(pattern, text, re.IGNORECASE)
|
642 |
+
if matches:
|
643 |
+
experience_found = True
|
644 |
+
for match in matches[:3]: # Limit to top 3 matches
|
645 |
+
if isinstance(match, tuple):
|
646 |
+
experience_lines.append(f"• {match[0]} {match[1]}")
|
647 |
+
else:
|
648 |
+
experience_lines.append(f"• {match}")
|
649 |
+
|
650 |
+
if experience_found:
|
651 |
+
return "\n".join(experience_lines)
|
652 |
+
return "No detailed work experience provided in resume"
|
653 |
+
else:
|
654 |
+
# Just take the first 5-7 lines of the work section as a summary
|
655 |
+
work_lines = []
|
656 |
+
company_count = 0
|
657 |
+
|
658 |
+
for line in work_section:
|
659 |
+
# New company entry often has a date
|
660 |
+
if re.search(r'(19|20)\d{2}', line):
|
661 |
+
company_count += 1
|
662 |
+
if company_count <= 3: # Limit to 3 most recent positions
|
663 |
+
work_lines.append(f"• {line}")
|
664 |
+
else:
|
665 |
+
break
|
666 |
+
elif company_count <= 3 and len(work_lines) < 10: # Limit total lines
|
667 |
+
if line.strip() and len(line) > 5:
|
668 |
+
work_lines.append(f" {line}")
|
669 |
+
|
670 |
+
if work_lines:
|
671 |
+
return "\n".join(work_lines)
|
672 |
+
return "Work experience mentioned but details unclear"
|
673 |
+
|
674 |
#####################################
|
675 |
# Function: Extract Job Requirements
|
676 |
#####################################
|