Spaces:
Sleeping
Sleeping
earlsab commited on
Commit ·
6ddba81
1
Parent(s): ee4b409
working matched skills view
Browse files
app.py
CHANGED
|
@@ -500,80 +500,6 @@ def create_html_output(job_result: Dict, resume_results: List[Dict], filenames:
|
|
| 500 |
avg_leadership = sum(leadership_counts) / len(leadership_counts) if leadership_counts else 0
|
| 501 |
avg_collaboration = sum(collaboration_counts) / len(collaboration_counts) if collaboration_counts else 0
|
| 502 |
|
| 503 |
-
# Create skills summary table
|
| 504 |
-
html += "<h3>Skills Summary</h3>"
|
| 505 |
-
html += "<div style='margin-bottom: 10px;'>"
|
| 506 |
-
html += "<button onclick='toggleSkillsView()' id='skillsToggleBtn' style='background-color: #4CAF50; color: white; padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer;'>Show Only Matched Skills</button>"
|
| 507 |
-
html += "</div>"
|
| 508 |
-
html += "<table style='width: 100%; border-collapse: collapse; margin-bottom: 20px;' id='skillsTable'>"
|
| 509 |
-
html += "<tr style='background-color: #eee;'><th style='padding: 8px; text-align: left; border: 1px solid #ddd;'>Skill</th>"
|
| 510 |
-
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Years of Experience</th>"
|
| 511 |
-
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Leadership</th>"
|
| 512 |
-
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Collaboration</th>"
|
| 513 |
-
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Match</th></tr>"
|
| 514 |
-
|
| 515 |
-
# Get all unique skills across all resumes
|
| 516 |
-
all_skills = set()
|
| 517 |
-
for resume_result in resume_results:
|
| 518 |
-
for skill in resume_result['skills']:
|
| 519 |
-
all_skills.add(skill['text'].lower())
|
| 520 |
-
|
| 521 |
-
# Create a list of skill data for sorting
|
| 522 |
-
skill_data = []
|
| 523 |
-
for skill in all_skills:
|
| 524 |
-
# Calculate total years of experience across all resumes
|
| 525 |
-
total_years = sum(skill_experience.get(skill, 0) for skill_experience in skill_experience_maps)
|
| 526 |
-
|
| 527 |
-
# Check if skill has leadership or collaboration in any resume
|
| 528 |
-
has_leadership = any(skill in skill_leadership for skill_leadership in skill_leadership_maps)
|
| 529 |
-
has_collaboration = any(skill in skill_collaboration for skill_collaboration in skill_collaboration_maps)
|
| 530 |
-
|
| 531 |
-
# Check if skill matches job requirements
|
| 532 |
-
is_match = skill in job_skills
|
| 533 |
-
|
| 534 |
-
skill_data.append({
|
| 535 |
-
'skill': skill,
|
| 536 |
-
'years': total_years,
|
| 537 |
-
'has_leadership': has_leadership,
|
| 538 |
-
'has_collaboration': has_collaboration,
|
| 539 |
-
'is_match': is_match
|
| 540 |
-
})
|
| 541 |
-
|
| 542 |
-
# Sort skills by years of experience (descending)
|
| 543 |
-
skill_data.sort(key=lambda x: (-x['years'], x['skill']))
|
| 544 |
-
|
| 545 |
-
# Add rows for each skill
|
| 546 |
-
for data in skill_data:
|
| 547 |
-
# Add row to summary table
|
| 548 |
-
html += f"<tr class='skill-row' data-match='{str(data['is_match']).lower()}'><td style='padding: 8px; border: 1px solid #ddd;'>{data['skill']}</td>"
|
| 549 |
-
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{data['years']:.1f}</td>"
|
| 550 |
-
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['has_leadership'] else 'red'};'>{'Yes' if data['has_leadership'] else 'No'}</td>"
|
| 551 |
-
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['has_collaboration'] else 'red'};'>{'Yes' if data['has_collaboration'] else 'No'}</td>"
|
| 552 |
-
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['is_match'] else 'red'};'>{'Yes' if data['is_match'] else 'No'}</td></tr>"
|
| 553 |
-
|
| 554 |
-
html += "</table>"
|
| 555 |
-
|
| 556 |
-
# Add JavaScript for toggle functionality
|
| 557 |
-
html += """
|
| 558 |
-
<script>
|
| 559 |
-
function toggleSkillsView() {
|
| 560 |
-
const button = document.getElementById('skillsToggleBtn');
|
| 561 |
-
const rows = document.querySelectorAll('.skill-row');
|
| 562 |
-
const showOnlyMatched = button.textContent.includes('Show Only Matched');
|
| 563 |
-
|
| 564 |
-
rows.forEach(row => {
|
| 565 |
-
if (showOnlyMatched) {
|
| 566 |
-
row.style.display = row.dataset.match === 'true' ? '' : 'none';
|
| 567 |
-
} else {
|
| 568 |
-
row.style.display = '';
|
| 569 |
-
}
|
| 570 |
-
});
|
| 571 |
-
|
| 572 |
-
button.textContent = showOnlyMatched ? 'Show All Skills' : 'Show Only Matched Skills';
|
| 573 |
-
}
|
| 574 |
-
</script>
|
| 575 |
-
"""
|
| 576 |
-
|
| 577 |
# Create summary table if multiple resumes
|
| 578 |
if multiple_resumes:
|
| 579 |
html += "<h3>Match Summary</h3>"
|
|
@@ -743,13 +669,92 @@ def create_html_output(job_result: Dict, resume_results: List[Dict], filenames:
|
|
| 743 |
html += f"<div id='resume-detail-{i}' class='resume-detail' style='margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; display: {display_style};'>"
|
| 744 |
html += f"<h3>{resume_file} Details</h3>"
|
| 745 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 746 |
# Display all skills found in the resume
|
| 747 |
html += "<p><strong>Skills Found:</strong></p>"
|
| 748 |
html += "<div style='background-color: #f0f0f0; padding: 10px; border-radius: 5px;'>"
|
| 749 |
|
| 750 |
-
# Get skill experience map for this resume
|
| 751 |
-
skill_experience = skill_experience_maps[i-1]
|
| 752 |
-
|
| 753 |
for skill in resume_result['skills']:
|
| 754 |
# Highlight matched skills
|
| 755 |
is_match = skill['text'].lower() in job_skills
|
|
|
|
| 500 |
avg_leadership = sum(leadership_counts) / len(leadership_counts) if leadership_counts else 0
|
| 501 |
avg_collaboration = sum(collaboration_counts) / len(collaboration_counts) if collaboration_counts else 0
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
# Create summary table if multiple resumes
|
| 504 |
if multiple_resumes:
|
| 505 |
html += "<h3>Match Summary</h3>"
|
|
|
|
| 669 |
html += f"<div id='resume-detail-{i}' class='resume-detail' style='margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; border-radius: 5px; display: {display_style};'>"
|
| 670 |
html += f"<h3>{resume_file} Details</h3>"
|
| 671 |
|
| 672 |
+
# Skills Summary specific to this resume - Now inside the detail section
|
| 673 |
+
html += "<h3>Skills Summary</h3>"
|
| 674 |
+
html += "<div style='margin-bottom: 10px;'>"
|
| 675 |
+
html += f"<button onclick='toggleSkillsView{i}()' id='skillsToggleBtn{i}' style='background-color: #4CAF50; color: white; padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer;'>Show All Skills</button>"
|
| 676 |
+
html += "</div>"
|
| 677 |
+
html += f"<table style='width: 100%; border-collapse: collapse; margin-bottom: 20px;' id='skillsTable{i}'>"
|
| 678 |
+
html += "<tr style='background-color: #eee;'><th style='padding: 8px; text-align: left; border: 1px solid #ddd;'>Skill</th>"
|
| 679 |
+
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Years of Experience</th>"
|
| 680 |
+
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Leadership</th>"
|
| 681 |
+
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Collaboration</th>"
|
| 682 |
+
html += "<th style='padding: 8px; text-align: center; border: 1px solid #ddd;'>Match</th></tr>"
|
| 683 |
+
|
| 684 |
+
# Get all unique skills for this specific resume
|
| 685 |
+
resume_skills = set()
|
| 686 |
+
for skill in resume_result['skills']:
|
| 687 |
+
resume_skills.add(skill['text'].lower())
|
| 688 |
+
|
| 689 |
+
# Get skill maps for this resume
|
| 690 |
+
skill_experience = skill_experience_maps[i-1]
|
| 691 |
+
skill_leadership = skill_leadership_maps[i-1]
|
| 692 |
+
skill_collaboration = skill_collaboration_maps[i-1]
|
| 693 |
+
|
| 694 |
+
# Create a list of skill data for sorting
|
| 695 |
+
skill_data = []
|
| 696 |
+
for skill in resume_skills:
|
| 697 |
+
# Get years of experience for this skill
|
| 698 |
+
years = skill_experience.get(skill, 0)
|
| 699 |
+
|
| 700 |
+
# Check if skill has leadership or collaboration
|
| 701 |
+
has_leadership = skill in skill_leadership
|
| 702 |
+
has_collaboration = skill in skill_collaboration
|
| 703 |
+
|
| 704 |
+
# Check if skill matches job requirements
|
| 705 |
+
is_match = skill in job_skills
|
| 706 |
+
|
| 707 |
+
skill_data.append({
|
| 708 |
+
'skill': skill,
|
| 709 |
+
'years': years,
|
| 710 |
+
'has_leadership': has_leadership,
|
| 711 |
+
'has_collaboration': has_collaboration,
|
| 712 |
+
'is_match': is_match
|
| 713 |
+
})
|
| 714 |
+
|
| 715 |
+
# Sort skills by years of experience (descending)
|
| 716 |
+
skill_data.sort(key=lambda x: (-x['years'], x['skill']))
|
| 717 |
+
|
| 718 |
+
# Add rows for each skill
|
| 719 |
+
for data in skill_data:
|
| 720 |
+
# Set initial display based on match (only show matched skills by default)
|
| 721 |
+
display = "none" if not data['is_match'] else ""
|
| 722 |
+
|
| 723 |
+
# Add row to summary table
|
| 724 |
+
html += f"<tr class='skill-row{i}' data-match='{str(data['is_match']).lower()}' style='display: {display};'>"
|
| 725 |
+
html += f"<td style='padding: 8px; border: 1px solid #ddd;'>{data['skill']}</td>"
|
| 726 |
+
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd;'>{data['years']:.1f}</td>"
|
| 727 |
+
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['has_leadership'] else 'red'};'>{'Yes' if data['has_leadership'] else 'No'}</td>"
|
| 728 |
+
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['has_collaboration'] else 'red'};'>{'Yes' if data['has_collaboration'] else 'No'}</td>"
|
| 729 |
+
html += f"<td style='padding: 8px; text-align: center; border: 1px solid #ddd; color: {'green' if data['is_match'] else 'red'};'>{'Yes' if data['is_match'] else 'No'}</td></tr>"
|
| 730 |
+
|
| 731 |
+
html += "</table>"
|
| 732 |
+
|
| 733 |
+
# Add JavaScript for toggle functionality for this specific resume's skills table
|
| 734 |
+
html += f"""
|
| 735 |
+
<script>
|
| 736 |
+
function toggleSkillsView{i}() {{
|
| 737 |
+
const button = document.getElementById('skillsToggleBtn{i}');
|
| 738 |
+
const rows = document.querySelectorAll('.skill-row{i}');
|
| 739 |
+
const showOnlyMatched = button.textContent.includes('Show All');
|
| 740 |
+
|
| 741 |
+
rows.forEach(row => {{
|
| 742 |
+
if (showOnlyMatched) {{
|
| 743 |
+
row.style.display = '';
|
| 744 |
+
}} else {{
|
| 745 |
+
row.style.display = row.dataset.match === 'true' ? '' : 'none';
|
| 746 |
+
}}
|
| 747 |
+
}});
|
| 748 |
+
|
| 749 |
+
button.textContent = showOnlyMatched ? 'Show Only Matched Skills' : 'Show All Skills';
|
| 750 |
+
}}
|
| 751 |
+
</script>
|
| 752 |
+
"""
|
| 753 |
+
|
| 754 |
# Display all skills found in the resume
|
| 755 |
html += "<p><strong>Skills Found:</strong></p>"
|
| 756 |
html += "<div style='background-color: #f0f0f0; padding: 10px; border-radius: 5px;'>"
|
| 757 |
|
|
|
|
|
|
|
|
|
|
| 758 |
for skill in resume_result['skills']:
|
| 759 |
# Highlight matched skills
|
| 760 |
is_match = skill['text'].lower() in job_skills
|