Spaces:
Sleeping
Sleeping
earlsab
commited on
Commit
·
ee4b409
1
Parent(s):
9b6fbe8
working skills outline
Browse files
app.py
CHANGED
|
@@ -416,6 +416,8 @@ def create_html_output(job_result: Dict, resume_results: List[Dict], filenames:
|
|
| 416 |
collaboration_counts = []
|
| 417 |
total_experiences = []
|
| 418 |
skill_experience_maps = []
|
|
|
|
|
|
|
| 419 |
|
| 420 |
for resume_result in resume_results:
|
| 421 |
# Count leadership and collaboration sentences
|
|
@@ -425,16 +427,28 @@ def create_html_output(job_result: Dict, resume_results: List[Dict], filenames:
|
|
| 425 |
# Calculate total experience
|
| 426 |
total_experience = 0
|
| 427 |
skill_experience = {}
|
|
|
|
|
|
|
| 428 |
|
| 429 |
if 'roles' in resume_result:
|
| 430 |
for role in resume_result['roles']:
|
| 431 |
-
# Count quality scores
|
| 432 |
if 'quality_scores' in role:
|
| 433 |
for score in role['quality_scores']:
|
| 434 |
if score['is_leadership']:
|
| 435 |
leadership_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
elif score['is_collaboration']:
|
| 437 |
collaboration_count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
|
| 439 |
# Calculate experience duration
|
| 440 |
if 'role_length' in role:
|
|
@@ -479,11 +493,87 @@ def create_html_output(job_result: Dict, resume_results: List[Dict], filenames:
|
|
| 479 |
collaboration_counts.append(collaboration_count)
|
| 480 |
total_experiences.append(total_experience)
|
| 481 |
skill_experience_maps.append(skill_experience)
|
|
|
|
|
|
|
| 482 |
|
| 483 |
# Calculate averages for leadership and collaboration
|
| 484 |
avg_leadership = sum(leadership_counts) / len(leadership_counts) if leadership_counts else 0
|
| 485 |
avg_collaboration = sum(collaboration_counts) / len(collaboration_counts) if collaboration_counts else 0
|
| 486 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
# Create summary table if multiple resumes
|
| 488 |
if multiple_resumes:
|
| 489 |
html += "<h3>Match Summary</h3>"
|
|
|
|
| 416 |
collaboration_counts = []
|
| 417 |
total_experiences = []
|
| 418 |
skill_experience_maps = []
|
| 419 |
+
skill_leadership_maps = [] # New map for tracking leadership skills
|
| 420 |
+
skill_collaboration_maps = [] # New map for tracking collaboration skills
|
| 421 |
|
| 422 |
for resume_result in resume_results:
|
| 423 |
# Count leadership and collaboration sentences
|
|
|
|
| 427 |
# Calculate total experience
|
| 428 |
total_experience = 0
|
| 429 |
skill_experience = {}
|
| 430 |
+
skill_leadership = {} # Track which skills have leadership statements
|
| 431 |
+
skill_collaboration = {} # Track which skills have collaboration statements
|
| 432 |
|
| 433 |
if 'roles' in resume_result:
|
| 434 |
for role in resume_result['roles']:
|
| 435 |
+
# Count quality scores and track skills with leadership/collaboration
|
| 436 |
if 'quality_scores' in role:
|
| 437 |
for score in role['quality_scores']:
|
| 438 |
if score['is_leadership']:
|
| 439 |
leadership_count += 1
|
| 440 |
+
# Extract skills from leadership statement
|
| 441 |
+
for skill in role.get('skills', []):
|
| 442 |
+
skill_name = skill.get('name', '').lower()
|
| 443 |
+
if skill_name:
|
| 444 |
+
skill_leadership[skill_name] = True
|
| 445 |
elif score['is_collaboration']:
|
| 446 |
collaboration_count += 1
|
| 447 |
+
# Extract skills from collaboration statement
|
| 448 |
+
for skill in role.get('skills', []):
|
| 449 |
+
skill_name = skill.get('name', '').lower()
|
| 450 |
+
if skill_name:
|
| 451 |
+
skill_collaboration[skill_name] = True
|
| 452 |
|
| 453 |
# Calculate experience duration
|
| 454 |
if 'role_length' in role:
|
|
|
|
| 493 |
collaboration_counts.append(collaboration_count)
|
| 494 |
total_experiences.append(total_experience)
|
| 495 |
skill_experience_maps.append(skill_experience)
|
| 496 |
+
skill_leadership_maps.append(skill_leadership)
|
| 497 |
+
skill_collaboration_maps.append(skill_collaboration)
|
| 498 |
|
| 499 |
# Calculate averages for leadership and collaboration
|
| 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>"
|