139 lines
4.9 KiB
PHP
139 lines
4.9 KiB
PHP
<?php
|
|
|
|
function calculate_achievements_score($resume) {
|
|
$keywords = ['achieved', 'accomplished', 'awarded', 'gained', 'increased', 'decreased', 'optimized'];
|
|
$score = 0;
|
|
foreach ($keywords as $keyword) {
|
|
if (stripos($resume, $keyword) !== false) {
|
|
$score += 5;
|
|
}
|
|
}
|
|
return min($score, 30);
|
|
}
|
|
|
|
function calculate_duration_score($resume) {
|
|
$keywords = ['years', 'months', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
|
|
$score = 0;
|
|
foreach ($keywords as $keyword) {
|
|
if (stripos($resume, $keyword) !== false) {
|
|
$score += 2;
|
|
}
|
|
}
|
|
return min($score, 20);
|
|
}
|
|
|
|
function calculate_skills_score($resume) {
|
|
$skills = ['php', 'javascript', 'python', 'java', 'c++', 'sql', 'html', 'css', 'react', 'angular', 'vue', 'node.js', 'aws', 'azure', 'gcp'];
|
|
$score = 0;
|
|
foreach ($skills as $skill) {
|
|
if (stripos($resume, $skill) !== false) {
|
|
$score += 2;
|
|
}
|
|
}
|
|
return min($score, 20);
|
|
}
|
|
|
|
function calculate_courses_score($resume) {
|
|
$keywords = ['course', 'certification', 'training', 'workshop'];
|
|
$score = 0;
|
|
foreach ($keywords as $keyword) {
|
|
if (stripos($resume, $keyword) !== false) {
|
|
$score += 5;
|
|
}
|
|
}
|
|
return min($score, 15);
|
|
}
|
|
|
|
function calculate_project_quality_score($resume) {
|
|
$keywords = ['deployed', 'live', 'production', 'github', 'portfolio', 'demo'];
|
|
$score = 0;
|
|
foreach ($keywords as $keyword) {
|
|
if (stripos($resume, $keyword) !== false) {
|
|
$score += 3;
|
|
}
|
|
}
|
|
return min($score, 15);
|
|
}
|
|
|
|
function calculate_impact_score($resume) {
|
|
$action_verbs = ['managed', 'led', 'developed', 'created', 'implemented', 'designed', 'analyzed', 'negotiated', 'achieved', 'accomplished', 'awarded', 'gained', 'increased', 'decreased', 'optimized'];
|
|
$action_verb_score = 0;
|
|
foreach ($action_verbs as $verb) {
|
|
$action_verb_score += substr_count(strtolower($resume), $verb);
|
|
}
|
|
$action_verb_score *= 2;
|
|
|
|
$quantifiable_results_score = 0;
|
|
preg_match_all('/\d+/?%?/', $resume, $matches);
|
|
$quantifiable_results_score = count($matches[0]) * 5;
|
|
|
|
$specific_achievements = ['award', 'promotion', 'led', 'managed', 'developed', 'created'];
|
|
$specific_achievements_score = 0;
|
|
foreach ($specific_achievements as $achievement) {
|
|
$specific_achievements_score += substr_count(strtolower($resume), $achievement);
|
|
}
|
|
$specific_achievements_score *= 3;
|
|
|
|
$total_score = $action_verb_score + $quantifiable_results_score + $specific_achievements_score;
|
|
return min($total_score, 100);
|
|
}
|
|
|
|
function detect_fake_content($resume) {
|
|
$flags = [];
|
|
|
|
$generic_phrases = ['team player', 'hard worker', 'results-oriented', 'good communication skills', 'detail-oriented'];
|
|
foreach ($generic_phrases as $phrase) {
|
|
if (stripos($resume, $phrase) !== false) {
|
|
$flags[] = 'Generic phrase found: "' . $phrase . '"';
|
|
}
|
|
}
|
|
|
|
$buzzwords = ['synergy', 'disruptive', 'paradigm shift', 'rockstar', 'ninja'];
|
|
foreach ($buzzwords as $word) {
|
|
if (stripos($resume, $word) !== false) {
|
|
$flags[] = 'Buzzword found: "' . $word . '"';
|
|
}
|
|
}
|
|
|
|
// Very basic check for overlapping dates - this is a simplified example
|
|
preg_match_all('/(\d{4})\s*-\s*(\d{4})/', $resume, $matches, PREG_SET_ORDER);
|
|
$dates = [];
|
|
foreach ($matches as $match) {
|
|
$dates[] = ['start' => (int)$match[1], 'end' => (int)$match[2]];
|
|
}
|
|
|
|
for ($i = 0; $i < count($dates); $i++) {
|
|
for ($j = $i + 1; $j < count($dates); $j++) {
|
|
if ($dates[$i]['start'] < $dates[$j]['end'] && $dates[$j]['start'] < $dates[$i]['end']) {
|
|
$flags[] = 'Potential overlapping dates found.';
|
|
break 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $flags;
|
|
}
|
|
|
|
function get_role_based_suggestions($resume, $role) {
|
|
$role_keywords = [
|
|
'software engineer' => ['php', 'javascript', 'python', 'java', 'c++', 'sql', 'html', 'css', 'react', 'angular', 'vue', 'node.js', 'aws', 'azure', 'gcp', 'docker', 'kubernetes', 'git'],
|
|
'product manager' => ['agile', 'scrum', 'roadmap', 'user stories', 'market research', 'competitive analysis', 'product launch', 'kpis', 'user feedback', 'a/b testing'],
|
|
'data scientist' => ['python', 'r', 'sql', 'machine learning', 'deep learning', 'tensorflow', 'pytorch', 'scikit-learn', 'pandas', 'numpy', 'data visualization', 'statistics']
|
|
];
|
|
|
|
$suggestions = [];
|
|
|
|
if (isset($role_keywords[$role])) {
|
|
$resume_words = str_word_count(strtolower($resume), 1);
|
|
$missing_keywords = array_diff($role_keywords[$role], $resume_words);
|
|
|
|
if (!empty($missing_keywords)) {
|
|
$suggestions['add'] = $missing_keywords;
|
|
}
|
|
} else {
|
|
$suggestions['error'] = 'Role not found. Please try one of the following: Software Engineer, Product Manager, Data Scientist.';
|
|
}
|
|
|
|
return $suggestions;
|
|
}
|