Spaces:
Runtime error
Runtime error
Upload 11 files
Browse files- .gitattributes +1 -0
- database.py +65 -0
- index.html +746 -0
- models.py +35 -0
- readme.md +219 -0
- requirements.txt +17 -0
- resume_analysis.db +3 -0
- run.py +15 -0
- server.py +476 -0
- setup.py +44 -0
- smart_setup.py +140 -0
- text_processor.py +375 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
resume_analysis.db filter=lfs diff=lfs merge=lfs -text
|
database.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# database.py
|
| 2 |
+
from sqlalchemy import create_engine, Column, Integer, String, Float, DateTime, Text, LargeBinary
|
| 3 |
+
from sqlalchemy.ext.declarative import declarative_base
|
| 4 |
+
from sqlalchemy.orm import sessionmaker
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
# SQLite database setup
|
| 8 |
+
SQLALCHEMY_DATABASE_URL = "sqlite:///./resume_analysis.db"
|
| 9 |
+
engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False})
|
| 10 |
+
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 11 |
+
Base = declarative_base()
|
| 12 |
+
|
| 13 |
+
# Database Models
|
| 14 |
+
class Resume(Base):
|
| 15 |
+
__tablename__ = "resumes"
|
| 16 |
+
|
| 17 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 18 |
+
filename = Column(String, index=True)
|
| 19 |
+
file_type = Column(String) # pdf, docx
|
| 20 |
+
file_content = Column(LargeBinary) # Store file binary data
|
| 21 |
+
extracted_text = Column(Text)
|
| 22 |
+
upload_date = Column(DateTime, default=datetime.utcnow)
|
| 23 |
+
|
| 24 |
+
class JobDescription(Base):
|
| 25 |
+
__tablename__ = "job_descriptions"
|
| 26 |
+
|
| 27 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 28 |
+
filename = Column(String, index=True)
|
| 29 |
+
file_type = Column(String)
|
| 30 |
+
file_content = Column(LargeBinary)
|
| 31 |
+
extracted_text = Column(Text)
|
| 32 |
+
upload_date = Column(DateTime, default=datetime.utcnow)
|
| 33 |
+
|
| 34 |
+
class Analysis(Base):
|
| 35 |
+
__tablename__ = "analyses"
|
| 36 |
+
|
| 37 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 38 |
+
resume_id = Column(Integer, index=True)
|
| 39 |
+
job_description_id = Column(Integer, index=True)
|
| 40 |
+
hard_score = Column(Float)
|
| 41 |
+
soft_score = Column(Float)
|
| 42 |
+
overall_score = Column(Float)
|
| 43 |
+
verdict = Column(String) # High, Medium, Low
|
| 44 |
+
missing_skills = Column(Text) # JSON string
|
| 45 |
+
feedback = Column(Text)
|
| 46 |
+
analysis_date = Column(DateTime, default=datetime.utcnow)
|
| 47 |
+
|
| 48 |
+
class ActivityLog(Base):
|
| 49 |
+
__tablename__ = "activity_logs"
|
| 50 |
+
|
| 51 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 52 |
+
action = Column(String) # upload, analyze, view
|
| 53 |
+
details = Column(Text)
|
| 54 |
+
timestamp = Column(DateTime, default=datetime.utcnow)
|
| 55 |
+
|
| 56 |
+
# Create tables
|
| 57 |
+
Base.metadata.create_all(bind=engine)
|
| 58 |
+
|
| 59 |
+
# Dependency to get DB session
|
| 60 |
+
def get_db():
|
| 61 |
+
db = SessionLocal()
|
| 62 |
+
try:
|
| 63 |
+
yield db
|
| 64 |
+
finally:
|
| 65 |
+
db.close()
|
index.html
ADDED
|
@@ -0,0 +1,746 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Resume Relevance Check System</title>
|
| 7 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.0/axios.min.js"></script>
|
| 8 |
+
<style>
|
| 9 |
+
* {
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 17 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
padding: 20px;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.container {
|
| 23 |
+
max-width: 1400px;
|
| 24 |
+
margin: 0 auto;
|
| 25 |
+
background: rgba(255, 255, 255, 0.95);
|
| 26 |
+
backdrop-filter: blur(10px);
|
| 27 |
+
border-radius: 20px;
|
| 28 |
+
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
| 29 |
+
overflow: hidden;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header {
|
| 33 |
+
background: linear-gradient(135deg, #2c3e50, #4a6741);
|
| 34 |
+
color: white;
|
| 35 |
+
padding: 30px;
|
| 36 |
+
text-align: center;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.header h1 {
|
| 40 |
+
font-size: 2.5rem;
|
| 41 |
+
margin-bottom: 10px;
|
| 42 |
+
font-weight: 700;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.header p {
|
| 46 |
+
font-size: 1.1rem;
|
| 47 |
+
opacity: 0.9;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.main-content {
|
| 51 |
+
display: grid;
|
| 52 |
+
grid-template-columns: 1fr 1fr;
|
| 53 |
+
gap: 30px;
|
| 54 |
+
padding: 30px;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.upload-section {
|
| 58 |
+
background: #f8f9fa;
|
| 59 |
+
border-radius: 15px;
|
| 60 |
+
padding: 25px;
|
| 61 |
+
border: 2px dashed #dee2e6;
|
| 62 |
+
transition: all 0.3s ease;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.upload-section:hover {
|
| 66 |
+
border-color: #667eea;
|
| 67 |
+
background: #f0f4ff;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.upload-section h3 {
|
| 71 |
+
color: #2c3e50;
|
| 72 |
+
margin-bottom: 20px;
|
| 73 |
+
font-size: 1.3rem;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.file-input-wrapper {
|
| 77 |
+
position: relative;
|
| 78 |
+
margin-bottom: 20px;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
.file-input {
|
| 82 |
+
display: none;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.file-input-label {
|
| 86 |
+
display: block;
|
| 87 |
+
padding: 15px 20px;
|
| 88 |
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
| 89 |
+
color: white;
|
| 90 |
+
border-radius: 10px;
|
| 91 |
+
cursor: pointer;
|
| 92 |
+
text-align: center;
|
| 93 |
+
transition: all 0.3s ease;
|
| 94 |
+
font-weight: 600;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.file-input-label:hover {
|
| 98 |
+
transform: translateY(-2px);
|
| 99 |
+
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.file-status {
|
| 103 |
+
margin-top: 10px;
|
| 104 |
+
padding: 10px;
|
| 105 |
+
border-radius: 8px;
|
| 106 |
+
background: #e8f5e8;
|
| 107 |
+
color: #2d5a2d;
|
| 108 |
+
font-size: 0.9rem;
|
| 109 |
+
display: none;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.btn {
|
| 113 |
+
background: linear-gradient(135deg, #28a745, #20c997);
|
| 114 |
+
color: white;
|
| 115 |
+
border: none;
|
| 116 |
+
padding: 15px 30px;
|
| 117 |
+
border-radius: 10px;
|
| 118 |
+
font-size: 1.1rem;
|
| 119 |
+
font-weight: 600;
|
| 120 |
+
cursor: pointer;
|
| 121 |
+
transition: all 0.3s ease;
|
| 122 |
+
width: 100%;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.btn:hover:not(:disabled) {
|
| 126 |
+
transform: translateY(-2px);
|
| 127 |
+
box-shadow: 0 10px 20px rgba(40, 167, 69, 0.3);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.btn:disabled {
|
| 131 |
+
background: #6c757d;
|
| 132 |
+
cursor: not-allowed;
|
| 133 |
+
transform: none;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.results-section {
|
| 137 |
+
background: #f8f9fa;
|
| 138 |
+
border-radius: 15px;
|
| 139 |
+
padding: 25px;
|
| 140 |
+
min-height: 400px;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.results-section h3 {
|
| 144 |
+
color: #2c3e50;
|
| 145 |
+
margin-bottom: 20px;
|
| 146 |
+
font-size: 1.3rem;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.score-card {
|
| 150 |
+
background: white;
|
| 151 |
+
border-radius: 12px;
|
| 152 |
+
padding: 20px;
|
| 153 |
+
margin-bottom: 20px;
|
| 154 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
|
| 155 |
+
border-left: 5px solid #667eea;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.score-row {
|
| 159 |
+
display: flex;
|
| 160 |
+
justify-content: space-between;
|
| 161 |
+
align-items: center;
|
| 162 |
+
margin-bottom: 15px;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.score-label {
|
| 166 |
+
font-weight: 600;
|
| 167 |
+
color: #2c3e50;
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
.score-value {
|
| 171 |
+
font-size: 1.2rem;
|
| 172 |
+
font-weight: 700;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.score-bar {
|
| 176 |
+
height: 8px;
|
| 177 |
+
background: #e9ecef;
|
| 178 |
+
border-radius: 4px;
|
| 179 |
+
overflow: hidden;
|
| 180 |
+
margin-top: 5px;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
.score-fill {
|
| 184 |
+
height: 100%;
|
| 185 |
+
background: linear-gradient(90deg, #28a745, #20c997);
|
| 186 |
+
transition: width 1s ease;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.verdict {
|
| 190 |
+
text-align: center;
|
| 191 |
+
padding: 15px;
|
| 192 |
+
border-radius: 10px;
|
| 193 |
+
font-size: 1.2rem;
|
| 194 |
+
font-weight: 700;
|
| 195 |
+
margin-bottom: 20px;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
.verdict.high {
|
| 199 |
+
background: #d4edda;
|
| 200 |
+
color: #155724;
|
| 201 |
+
border: 2px solid #c3e6cb;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
.verdict.medium {
|
| 205 |
+
background: #fff3cd;
|
| 206 |
+
color: #856404;
|
| 207 |
+
border: 2px solid #ffeaa7;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
.verdict.low {
|
| 211 |
+
background: #f8d7da;
|
| 212 |
+
color: #721c24;
|
| 213 |
+
border: 2px solid #f5c6cb;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.feedback-section {
|
| 217 |
+
background: white;
|
| 218 |
+
border-radius: 12px;
|
| 219 |
+
padding: 20px;
|
| 220 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.feedback-section h4 {
|
| 224 |
+
color: #2c3e50;
|
| 225 |
+
margin-bottom: 15px;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
.missing-skills {
|
| 229 |
+
display: flex;
|
| 230 |
+
flex-wrap: wrap;
|
| 231 |
+
gap: 8px;
|
| 232 |
+
margin-bottom: 15px;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
.skill-tag {
|
| 236 |
+
background: #667eea;
|
| 237 |
+
color: white;
|
| 238 |
+
padding: 5px 12px;
|
| 239 |
+
border-radius: 20px;
|
| 240 |
+
font-size: 0.9rem;
|
| 241 |
+
font-weight: 500;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.dashboard-section {
|
| 245 |
+
margin-top: 40px;
|
| 246 |
+
padding: 30px;
|
| 247 |
+
background: #f8f9fa;
|
| 248 |
+
border-radius: 15px;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.dashboard-header {
|
| 252 |
+
display: flex;
|
| 253 |
+
justify-content: space-between;
|
| 254 |
+
align-items: center;
|
| 255 |
+
margin-bottom: 20px;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
.search-bar {
|
| 259 |
+
padding: 12px 20px;
|
| 260 |
+
border: 2px solid #dee2e6;
|
| 261 |
+
border-radius: 10px;
|
| 262 |
+
font-size: 1rem;
|
| 263 |
+
width: 300px;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
.history-table {
|
| 267 |
+
background: white;
|
| 268 |
+
border-radius: 12px;
|
| 269 |
+
overflow: hidden;
|
| 270 |
+
box-shadow: 0 5px 15px rgba(0,0,0,0.08);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.table-header {
|
| 274 |
+
background: #2c3e50;
|
| 275 |
+
color: white;
|
| 276 |
+
padding: 15px;
|
| 277 |
+
display: grid;
|
| 278 |
+
grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
|
| 279 |
+
gap: 20px;
|
| 280 |
+
font-weight: 600;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
.table-row {
|
| 284 |
+
padding: 15px;
|
| 285 |
+
display: grid;
|
| 286 |
+
grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
|
| 287 |
+
gap: 20px;
|
| 288 |
+
border-bottom: 1px solid #dee2e6;
|
| 289 |
+
align-items: center;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
.table-row:hover {
|
| 293 |
+
background: #f8f9fa;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.loading {
|
| 297 |
+
display: none;
|
| 298 |
+
text-align: center;
|
| 299 |
+
padding: 40px;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.spinner {
|
| 303 |
+
border: 4px solid #f3f3f3;
|
| 304 |
+
border-top: 4px solid #667eea;
|
| 305 |
+
border-radius: 50%;
|
| 306 |
+
width: 50px;
|
| 307 |
+
height: 50px;
|
| 308 |
+
animation: spin 1s linear infinite;
|
| 309 |
+
margin: 0 auto 20px;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
@keyframes spin {
|
| 313 |
+
0% { transform: rotate(0deg); }
|
| 314 |
+
100% { transform: rotate(360deg); }
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
.error-message {
|
| 318 |
+
background: #f8d7da;
|
| 319 |
+
color: #721c24;
|
| 320 |
+
padding: 15px;
|
| 321 |
+
border-radius: 10px;
|
| 322 |
+
margin: 20px 0;
|
| 323 |
+
border: 1px solid #f5c6cb;
|
| 324 |
+
display: none;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
@media (max-width: 768px) {
|
| 328 |
+
.main-content {
|
| 329 |
+
grid-template-columns: 1fr;
|
| 330 |
+
gap: 20px;
|
| 331 |
+
padding: 20px;
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
.header h1 {
|
| 335 |
+
font-size: 2rem;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
.table-header,
|
| 339 |
+
.table-row {
|
| 340 |
+
grid-template-columns: 1fr;
|
| 341 |
+
gap: 10px;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.dashboard-header {
|
| 345 |
+
flex-direction: column;
|
| 346 |
+
gap: 15px;
|
| 347 |
+
align-items: stretch;
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
.search-bar {
|
| 351 |
+
width: 100%;
|
| 352 |
+
}
|
| 353 |
+
}
|
| 354 |
+
</style>
|
| 355 |
+
</head>
|
| 356 |
+
<body>
|
| 357 |
+
<div class="container">
|
| 358 |
+
<div class="header">
|
| 359 |
+
<h1>Resume Relevance Check System</h1>
|
| 360 |
+
<p>AI-Powered Resume Analysis & Job Matching Platform</p>
|
| 361 |
+
</div>
|
| 362 |
+
|
| 363 |
+
<div class="main-content">
|
| 364 |
+
<div class="upload-section">
|
| 365 |
+
<h3>π Upload Resume</h3>
|
| 366 |
+
<div class="file-input-wrapper">
|
| 367 |
+
<input type="file" id="resumeFile" class="file-input" accept=".pdf,.docx">
|
| 368 |
+
<label for="resumeFile" class="file-input-label">
|
| 369 |
+
Choose Resume (PDF/DOCX)
|
| 370 |
+
</label>
|
| 371 |
+
<div class="file-status" id="resumeStatus"></div>
|
| 372 |
+
</div>
|
| 373 |
+
|
| 374 |
+
<h3>πΌ Upload Job Description</h3>
|
| 375 |
+
<div class="file-input-wrapper">
|
| 376 |
+
<input type="file" id="jobFile" class="file-input" accept=".pdf,.docx,.txt">
|
| 377 |
+
<label for="jobFile" class="file-input-label">
|
| 378 |
+
Choose Job Description
|
| 379 |
+
</label>
|
| 380 |
+
<div class="file-status" id="jobStatus"></div>
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<button class="btn" id="analyzeBtn" onclick="analyzeResume()" disabled>
|
| 384 |
+
π Analyze Resume
|
| 385 |
+
</button>
|
| 386 |
+
</div>
|
| 387 |
+
|
| 388 |
+
<div class="results-section">
|
| 389 |
+
<h3>π Analysis Results</h3>
|
| 390 |
+
<div id="loadingDiv" class="loading">
|
| 391 |
+
<div class="spinner"></div>
|
| 392 |
+
<p>Analyzing resume with AI...</p>
|
| 393 |
+
</div>
|
| 394 |
+
|
| 395 |
+
<div id="errorDiv" class="error-message"></div>
|
| 396 |
+
|
| 397 |
+
<div id="resultsDiv" style="display: none;">
|
| 398 |
+
<div class="score-card">
|
| 399 |
+
<div class="score-row">
|
| 400 |
+
<span class="score-label">Hard Match Score</span>
|
| 401 |
+
<span class="score-value" id="hardScore">0%</span>
|
| 402 |
+
</div>
|
| 403 |
+
<div class="score-bar">
|
| 404 |
+
<div class="score-fill" id="hardBar" style="width: 0%"></div>
|
| 405 |
+
</div>
|
| 406 |
+
</div>
|
| 407 |
+
|
| 408 |
+
<div class="score-card">
|
| 409 |
+
<div class="score-row">
|
| 410 |
+
<span class="score-label">Soft Match Score</span>
|
| 411 |
+
<span class="score-value" id="softScore">0%</span>
|
| 412 |
+
</div>
|
| 413 |
+
<div class="score-bar">
|
| 414 |
+
<div class="score-fill" id="softBar" style="width: 0%"></div>
|
| 415 |
+
</div>
|
| 416 |
+
</div>
|
| 417 |
+
|
| 418 |
+
<div class="score-card">
|
| 419 |
+
<div class="score-row">
|
| 420 |
+
<span class="score-label">Overall Relevance</span>
|
| 421 |
+
<span class="score-value" id="overallScore">0%</span>
|
| 422 |
+
</div>
|
| 423 |
+
<div class="score-bar">
|
| 424 |
+
<div class="score-fill" id="overallBar" style="width: 0%"></div>
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
+
|
| 428 |
+
<div class="verdict" id="verdictDiv">
|
| 429 |
+
Analyzing...
|
| 430 |
+
</div>
|
| 431 |
+
|
| 432 |
+
<div class="feedback-section">
|
| 433 |
+
<h4>Missing Skills</h4>
|
| 434 |
+
<div class="missing-skills" id="missingSkills"></div>
|
| 435 |
+
|
| 436 |
+
<h4>Personalized Feedback</h4>
|
| 437 |
+
<p id="feedbackText">Analysis in progress...</p>
|
| 438 |
+
</div>
|
| 439 |
+
</div>
|
| 440 |
+
</div>
|
| 441 |
+
</div>
|
| 442 |
+
|
| 443 |
+
<div class="dashboard-section">
|
| 444 |
+
<div class="dashboard-header">
|
| 445 |
+
<h3>π Analysis History</h3>
|
| 446 |
+
<input type="text" class="search-bar" placeholder="Search resumes..." id="searchBar" onkeyup="filterHistory()">
|
| 447 |
+
</div>
|
| 448 |
+
|
| 449 |
+
<div class="history-table">
|
| 450 |
+
<div class="table-header">
|
| 451 |
+
<div>Resume Name</div>
|
| 452 |
+
<div>Date</div>
|
| 453 |
+
<div>Overall Score</div>
|
| 454 |
+
<div>Verdict</div>
|
| 455 |
+
<div>Action</div>
|
| 456 |
+
</div>
|
| 457 |
+
<div id="historyBody">
|
| 458 |
+
<!-- History will be loaded dynamically -->
|
| 459 |
+
</div>
|
| 460 |
+
</div>
|
| 461 |
+
</div>
|
| 462 |
+
</div>
|
| 463 |
+
|
| 464 |
+
<script>
|
| 465 |
+
// Backend API configuration
|
| 466 |
+
const API_BASE_URL = 'http://127.0.0.1:8000';
|
| 467 |
+
let analysisHistory = [];
|
| 468 |
+
let uploadedResumeId = null;
|
| 469 |
+
let uploadedJobId = null;
|
| 470 |
+
|
| 471 |
+
// File upload handlers
|
| 472 |
+
document.getElementById('resumeFile').addEventListener('change', async function(e) {
|
| 473 |
+
const file = e.target.files[0];
|
| 474 |
+
if (file) {
|
| 475 |
+
try {
|
| 476 |
+
const response = await uploadResume(file);
|
| 477 |
+
uploadedResumeId = response.resume_id;
|
| 478 |
+
document.getElementById('resumeStatus').innerHTML = `β ${file.name} uploaded successfully<br><small>Preview: ${response.extracted_text_preview}</small>`;
|
| 479 |
+
document.getElementById('resumeStatus').style.display = 'block';
|
| 480 |
+
document.getElementById('resumeStatus').style.background = '#e8f5e8';
|
| 481 |
+
document.getElementById('resumeStatus').style.color = '#2d5a2d';
|
| 482 |
+
checkFilesSelected();
|
| 483 |
+
} catch (error) {
|
| 484 |
+
showError('Failed to upload resume: ' + error.message);
|
| 485 |
+
document.getElementById('resumeStatus').innerHTML = `β Failed to upload ${file.name}`;
|
| 486 |
+
document.getElementById('resumeStatus').style.display = 'block';
|
| 487 |
+
document.getElementById('resumeStatus').style.background = '#f8d7da';
|
| 488 |
+
document.getElementById('resumeStatus').style.color = '#721c24';
|
| 489 |
+
}
|
| 490 |
+
}
|
| 491 |
+
});
|
| 492 |
+
|
| 493 |
+
document.getElementById('jobFile').addEventListener('change', async function(e) {
|
| 494 |
+
const file = e.target.files[0];
|
| 495 |
+
if (file) {
|
| 496 |
+
try {
|
| 497 |
+
const response = await uploadJobDescription(file);
|
| 498 |
+
uploadedJobId = response.job_description_id;
|
| 499 |
+
document.getElementById('jobStatus').innerHTML = `β ${file.name} uploaded successfully<br><small>Preview: ${response.extracted_text_preview}</small>`;
|
| 500 |
+
document.getElementById('jobStatus').style.display = 'block';
|
| 501 |
+
document.getElementById('jobStatus').style.background = '#e8f5e8';
|
| 502 |
+
document.getElementById('jobStatus').style.color = '#2d5a2d';
|
| 503 |
+
checkFilesSelected();
|
| 504 |
+
} catch (error) {
|
| 505 |
+
showError('Failed to upload job description: ' + error.message);
|
| 506 |
+
document.getElementById('jobStatus').innerHTML = `β Failed to upload ${file.name}`;
|
| 507 |
+
document.getElementById('jobStatus').style.display = 'block';
|
| 508 |
+
document.getElementById('jobStatus').style.background = '#f8d7da';
|
| 509 |
+
document.getElementById('jobStatus').style.color = '#721c24';
|
| 510 |
+
}
|
| 511 |
+
}
|
| 512 |
+
});
|
| 513 |
+
|
| 514 |
+
function checkFilesSelected() {
|
| 515 |
+
document.getElementById('analyzeBtn').disabled = !(uploadedResumeId && uploadedJobId);
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
// API functions
|
| 519 |
+
async function uploadResume(file) {
|
| 520 |
+
const formData = new FormData();
|
| 521 |
+
formData.append('file', file);
|
| 522 |
+
|
| 523 |
+
const response = await fetch(`${API_BASE_URL}/upload/resume/`, {
|
| 524 |
+
method: 'POST',
|
| 525 |
+
body: formData
|
| 526 |
+
});
|
| 527 |
+
|
| 528 |
+
if (!response.ok) {
|
| 529 |
+
const error = await response.json();
|
| 530 |
+
throw new Error(error.detail || 'Upload failed');
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
return await response.json();
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
async function uploadJobDescription(file) {
|
| 537 |
+
const formData = new FormData();
|
| 538 |
+
formData.append('file', file);
|
| 539 |
+
|
| 540 |
+
const response = await fetch(`${API_BASE_URL}/upload/job-description/`, {
|
| 541 |
+
method: 'POST',
|
| 542 |
+
body: formData
|
| 543 |
+
});
|
| 544 |
+
|
| 545 |
+
if (!response.ok) {
|
| 546 |
+
const error = await response.json();
|
| 547 |
+
throw new Error(error.detail || 'Upload failed');
|
| 548 |
+
}
|
| 549 |
+
|
| 550 |
+
return await response.json();
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
async function analyzeResumeAPI() {
|
| 554 |
+
const formData = new FormData();
|
| 555 |
+
formData.append('resume_id', uploadedResumeId);
|
| 556 |
+
formData.append('job_description_id', uploadedJobId);
|
| 557 |
+
|
| 558 |
+
const response = await fetch(`${API_BASE_URL}/analyze/`, {
|
| 559 |
+
method: 'POST',
|
| 560 |
+
body: formData
|
| 561 |
+
});
|
| 562 |
+
|
| 563 |
+
if (!response.ok) {
|
| 564 |
+
const error = await response.json();
|
| 565 |
+
throw new Error(error.detail || 'Analysis failed');
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
return await response.json();
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
async function loadAnalysisHistory() {
|
| 572 |
+
try {
|
| 573 |
+
const response = await fetch(`${API_BASE_URL}/analyses/`);
|
| 574 |
+
if (response.ok) {
|
| 575 |
+
analysisHistory = await response.json();
|
| 576 |
+
updateHistoryDisplay();
|
| 577 |
+
} else {
|
| 578 |
+
console.log('No analysis history available or server not running');
|
| 579 |
+
}
|
| 580 |
+
} catch (error) {
|
| 581 |
+
console.error('Failed to load analysis history:', error);
|
| 582 |
+
// Don't show error to user as this might be normal on first run
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
|
| 586 |
+
function showError(message) {
|
| 587 |
+
const errorDiv = document.getElementById('errorDiv');
|
| 588 |
+
errorDiv.textContent = message;
|
| 589 |
+
errorDiv.style.display = 'block';
|
| 590 |
+
setTimeout(() => {
|
| 591 |
+
errorDiv.style.display = 'none';
|
| 592 |
+
}, 8000);
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
async function analyzeResume() {
|
| 596 |
+
const loadingDiv = document.getElementById('loadingDiv');
|
| 597 |
+
const resultsDiv = document.getElementById('resultsDiv');
|
| 598 |
+
const errorDiv = document.getElementById('errorDiv');
|
| 599 |
+
|
| 600 |
+
// Show loading
|
| 601 |
+
loadingDiv.style.display = 'block';
|
| 602 |
+
resultsDiv.style.display = 'none';
|
| 603 |
+
errorDiv.style.display = 'none';
|
| 604 |
+
|
| 605 |
+
try {
|
| 606 |
+
// Call real API
|
| 607 |
+
const results = await analyzeResumeAPI();
|
| 608 |
+
|
| 609 |
+
// Update UI with results
|
| 610 |
+
updateResults(results, results.verdict, results.verdict.toLowerCase());
|
| 611 |
+
|
| 612 |
+
// Refresh history from backend
|
| 613 |
+
await loadAnalysisHistory();
|
| 614 |
+
|
| 615 |
+
// Hide loading, show results
|
| 616 |
+
loadingDiv.style.display = 'none';
|
| 617 |
+
resultsDiv.style.display = 'block';
|
| 618 |
+
|
| 619 |
+
} catch (error) {
|
| 620 |
+
loadingDiv.style.display = 'none';
|
| 621 |
+
showError('Error analyzing resume: ' + error.message);
|
| 622 |
+
}
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
function updateResults(results, verdict, verdictClass) {
|
| 626 |
+
// Update scores
|
| 627 |
+
document.getElementById('hardScore').textContent = results.hard_score + '%';
|
| 628 |
+
document.getElementById('softScore').textContent = results.soft_score + '%';
|
| 629 |
+
document.getElementById('overallScore').textContent = results.overall_score + '%';
|
| 630 |
+
|
| 631 |
+
// Update progress bars
|
| 632 |
+
setTimeout(() => {
|
| 633 |
+
document.getElementById('hardBar').style.width = results.hard_score + '%';
|
| 634 |
+
document.getElementById('softBar').style.width = results.soft_score + '%';
|
| 635 |
+
document.getElementById('overallBar').style.width = results.overall_score + '%';
|
| 636 |
+
}, 500);
|
| 637 |
+
|
| 638 |
+
// Update verdict
|
| 639 |
+
const verdictDiv = document.getElementById('verdictDiv');
|
| 640 |
+
verdictDiv.textContent = verdict + ' Suitability';
|
| 641 |
+
verdictDiv.className = 'verdict ' + verdictClass;
|
| 642 |
+
|
| 643 |
+
// Update missing skills
|
| 644 |
+
const skillsContainer = document.getElementById('missingSkills');
|
| 645 |
+
skillsContainer.innerHTML = '';
|
| 646 |
+
results.missing_skills.forEach(skill => {
|
| 647 |
+
const skillTag = document.createElement('span');
|
| 648 |
+
skillTag.className = 'skill-tag';
|
| 649 |
+
skillTag.textContent = skill;
|
| 650 |
+
skillsContainer.appendChild(skillTag);
|
| 651 |
+
});
|
| 652 |
+
|
| 653 |
+
// Update feedback
|
| 654 |
+
document.getElementById('feedbackText').textContent = results.feedback;
|
| 655 |
+
}
|
| 656 |
+
|
| 657 |
+
function updateHistoryDisplay() {
|
| 658 |
+
const historyBody = document.getElementById('historyBody');
|
| 659 |
+
historyBody.innerHTML = '';
|
| 660 |
+
|
| 661 |
+
if (analysisHistory.length === 0) {
|
| 662 |
+
const row = document.createElement('div');
|
| 663 |
+
row.className = 'table-row';
|
| 664 |
+
row.style.textAlign = 'center';
|
| 665 |
+
row.style.gridColumn = '1 / -1';
|
| 666 |
+
row.style.color = '#6c757d';
|
| 667 |
+
row.style.fontStyle = 'italic';
|
| 668 |
+
row.innerHTML = '<div style="grid-column: 1 / -1;">No analyses yet. Upload files and analyze to see history here.</div>';
|
| 669 |
+
historyBody.appendChild(row);
|
| 670 |
+
return;
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
analysisHistory.forEach(entry => {
|
| 674 |
+
const row = document.createElement('div');
|
| 675 |
+
row.className = 'table-row';
|
| 676 |
+
|
| 677 |
+
let verdictColor = '#dc3545'; // red
|
| 678 |
+
if (entry.verdict === 'High') verdictColor = '#28a745'; // green
|
| 679 |
+
else if (entry.verdict === 'Medium') verdictColor = '#ffc107'; // yellow
|
| 680 |
+
|
| 681 |
+
const analysisDate = new Date(entry.analysis_date).toLocaleDateString();
|
| 682 |
+
|
| 683 |
+
row.innerHTML = `
|
| 684 |
+
<div>${entry.resume_filename}</div>
|
| 685 |
+
<div>${analysisDate}</div>
|
| 686 |
+
<div>${Math.round(entry.overall_score)}%</div>
|
| 687 |
+
<div style="color: ${verdictColor}; font-weight: 600;">${entry.verdict}</div>
|
| 688 |
+
<div><button class="btn" style="padding: 8px 16px; font-size: 0.9rem;" onclick="viewDetails(${entry.id})">View Details</button></div>
|
| 689 |
+
`;
|
| 690 |
+
|
| 691 |
+
historyBody.appendChild(row);
|
| 692 |
+
});
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
async function viewDetails(analysisId) {
|
| 696 |
+
try {
|
| 697 |
+
const response = await fetch(`${API_BASE_URL}/analyses/${analysisId}`);
|
| 698 |
+
if (response.ok) {
|
| 699 |
+
const entry = await response.json();
|
| 700 |
+
updateResults({
|
| 701 |
+
hard_score: entry.hard_score,
|
| 702 |
+
soft_score: entry.soft_score,
|
| 703 |
+
overall_score: entry.overall_score,
|
| 704 |
+
missing_skills: entry.missing_skills,
|
| 705 |
+
feedback: entry.feedback
|
| 706 |
+
}, entry.verdict, entry.verdict.toLowerCase());
|
| 707 |
+
|
| 708 |
+
document.getElementById('resultsDiv').style.display = 'block';
|
| 709 |
+
document.getElementById('resultsDiv').scrollIntoView({ behavior: 'smooth' });
|
| 710 |
+
}
|
| 711 |
+
} catch (error) {
|
| 712 |
+
showError('Failed to load analysis details');
|
| 713 |
+
}
|
| 714 |
+
}
|
| 715 |
+
|
| 716 |
+
function filterHistory() {
|
| 717 |
+
const searchTerm = document.getElementById('searchBar').value.toLowerCase();
|
| 718 |
+
const rows = document.querySelectorAll('#historyBody .table-row');
|
| 719 |
+
|
| 720 |
+
rows.forEach(row => {
|
| 721 |
+
const resumeName = row.querySelector('div').textContent.toLowerCase();
|
| 722 |
+
if (resumeName.includes('no analyses yet')) {
|
| 723 |
+
return; // Don't filter the "no analyses" message
|
| 724 |
+
}
|
| 725 |
+
row.style.display = resumeName.includes(searchTerm) ? 'grid' : 'none';
|
| 726 |
+
});
|
| 727 |
+
}
|
| 728 |
+
|
| 729 |
+
// Initialize application
|
| 730 |
+
window.addEventListener('load', async () => {
|
| 731 |
+
await loadAnalysisHistory();
|
| 732 |
+
|
| 733 |
+
// Check if backend is running
|
| 734 |
+
try {
|
| 735 |
+
const response = await fetch(`${API_BASE_URL}/`);
|
| 736 |
+
if (response.ok) {
|
| 737 |
+
console.log('β
Backend server connected successfully');
|
| 738 |
+
}
|
| 739 |
+
} catch (error) {
|
| 740 |
+
showError('β οΈ Backend server not running. Please start the FastAPI server first.');
|
| 741 |
+
console.error('Backend connection failed:', error);
|
| 742 |
+
}
|
| 743 |
+
});
|
| 744 |
+
</script>
|
| 745 |
+
</body>
|
| 746 |
+
</html>
|
models.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# models.py
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from typing import List, Optional
|
| 4 |
+
from datetime import datetime
|
| 5 |
+
|
| 6 |
+
class ResumeUpload(BaseModel):
|
| 7 |
+
filename: str
|
| 8 |
+
file_type: str
|
| 9 |
+
|
| 10 |
+
class JobDescriptionUpload(BaseModel):
|
| 11 |
+
filename: str
|
| 12 |
+
file_type: str
|
| 13 |
+
|
| 14 |
+
class AnalysisResult(BaseModel):
|
| 15 |
+
id: int
|
| 16 |
+
resume_filename: str
|
| 17 |
+
hard_score: float
|
| 18 |
+
soft_score: float
|
| 19 |
+
overall_score: float
|
| 20 |
+
verdict: str
|
| 21 |
+
missing_skills: List[str]
|
| 22 |
+
feedback: str
|
| 23 |
+
analysis_date: datetime
|
| 24 |
+
|
| 25 |
+
class AnalysisRequest(BaseModel):
|
| 26 |
+
resume_id: int
|
| 27 |
+
job_description_id: int
|
| 28 |
+
|
| 29 |
+
class AnalysisResponse(BaseModel):
|
| 30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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Resume Relevance Check System - Complete Setup Guide
|
| 2 |
+
|
| 3 |
+
## π Overview
|
| 4 |
+
This is a complete full-stack Resume Relevance Check System that uses FastAPI backend with SQLite database and AI-powered analysis capabilities.
|
| 5 |
+
|
| 6 |
+
## π Project Structure
|
| 7 |
+
```
|
| 8 |
+
resume_relevance_system/
|
| 9 |
+
βββ server.py # FastAPI backend server
|
| 10 |
+
βββ database.py # SQLite database models and configuration
|
| 11 |
+
βββ models.py # Pydantic models for API
|
| 12 |
+
βββ text_processor.py # AI/NLP processing engine
|
| 13 |
+
βββ run.py # Server startup script
|
| 14 |
+
βββ setup.py # Installation script
|
| 15 |
+
βββ requirements.txt # Python dependencies
|
| 16 |
+
βββ index.html # Frontend web application
|
| 17 |
+
βββ resume_analysis.db # SQLite database (created automatically)
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
## β‘ Quick Start
|
| 21 |
+
|
| 22 |
+
### 1. Clone/Download Project Files
|
| 23 |
+
Create a new directory and save all the backend files from the FastAPI artifact into separate Python files.
|
| 24 |
+
|
| 25 |
+
### 2. Install Dependencies
|
| 26 |
+
```bash
|
| 27 |
+
# Option 1: Run the setup script
|
| 28 |
+
python setup.py
|
| 29 |
+
|
| 30 |
+
# Option 2: Install manually
|
| 31 |
+
pip install fastapi==0.104.1 uvicorn==0.24.0 sqlalchemy==2.0.23 python-multipart==0.0.6 PyMuPDF==1.23.8 python-docx==1.1.0 sentence-transformers==2.2.2 scikit-learn==1.3.2 python-dotenv==1.0.0 pydantic==2.5.0 aiofiles==23.2.1
|
| 32 |
+
|
| 33 |
+
# Install spaCy English model (optional but recommended)
|
| 34 |
+
python -m spacy download en_core_web_sm
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### 3. Start the Backend Server
|
| 38 |
+
```bash
|
| 39 |
+
# Option 1: Using the run script
|
| 40 |
+
python run.py
|
| 41 |
+
|
| 42 |
+
# Option 2: Direct uvicorn command
|
| 43 |
+
uvicorn server:app --reload --host 127.0.0.1 --port 8000
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### 4. Open the Frontend
|
| 47 |
+
- Save the updated HTML file as `index.html`
|
| 48 |
+
- Open `index.html` in your web browser
|
| 49 |
+
- The frontend will automatically connect to the backend at `http://127.0.0.1:8000`
|
| 50 |
+
|
| 51 |
+
## π§ Configuration
|
| 52 |
+
|
| 53 |
+
### Backend Configuration
|
| 54 |
+
The system uses SQLite by default. To change to PostgreSQL for production:
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
# In database.py, replace:
|
| 58 |
+
SQLALCHEMY_DATABASE_URL = "sqlite:///./resume_analysis.db"
|
| 59 |
+
|
| 60 |
+
# With:
|
| 61 |
+
SQLALCHEMY_DATABASE_URL = "postgresql://username:password@localhost/resume_analysis"
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### CORS Configuration
|
| 65 |
+
For production, update the CORS settings in `server.py`:
|
| 66 |
+
|
| 67 |
+
```python
|
| 68 |
+
app.add_middleware(
|
| 69 |
+
CORSMiddleware,
|
| 70 |
+
allow_origins=["https://yourdomain.com"], # Your frontend URL
|
| 71 |
+
allow_credentials=True,
|
| 72 |
+
allow_methods=["*"],
|
| 73 |
+
allow_headers=["*"],
|
| 74 |
+
)
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## π Database Schema
|
| 78 |
+
|
| 79 |
+
### Tables Created Automatically:
|
| 80 |
+
- **resumes**: Stores uploaded resume files and extracted text
|
| 81 |
+
- **job_descriptions**: Stores job description files and text
|
| 82 |
+
- **analyses**: Stores analysis results and scores
|
| 83 |
+
- **activity_logs**: Tracks user activities and system events
|
| 84 |
+
|
| 85 |
+
## π€ AI/NLP Features
|
| 86 |
+
|
| 87 |
+
### Text Processing Capabilities:
|
| 88 |
+
- **PDF/DOCX Extraction**: Using PyMuPDF and python-docx
|
| 89 |
+
- **Hard Match Scoring**: TF-IDF vectorization and keyword matching
|
| 90 |
+
- **Soft Match Scoring**: Sentence transformers with cosine similarity
|
| 91 |
+
- **Skill Extraction**: NLP-based skill identification
|
| 92 |
+
- **Feedback Generation**: Automated personalized recommendations
|
| 93 |
+
|
| 94 |
+
### Supported File Types:
|
| 95 |
+
- **Resumes**: PDF, DOCX
|
| 96 |
+
- **Job Descriptions**: PDF, DOCX, TXT
|
| 97 |
+
|
| 98 |
+
## π API Endpoints
|
| 99 |
+
|
| 100 |
+
### File Upload
|
| 101 |
+
- `POST /upload/resume/` - Upload resume file
|
| 102 |
+
- `POST /upload/job-description/` - Upload job description
|
| 103 |
+
|
| 104 |
+
### Analysis
|
| 105 |
+
- `POST /analyze/` - Analyze resume against job description
|
| 106 |
+
- `GET /analyses/` - Get analysis history
|
| 107 |
+
- `GET /analyses/{id}` - Get specific analysis details
|
| 108 |
+
|
| 109 |
+
### Data Management
|
| 110 |
+
- `GET /resumes/` - List uploaded resumes
|
| 111 |
+
- `GET /job-descriptions/` - List uploaded job descriptions
|
| 112 |
+
- `DELETE /resumes/{id}` - Delete resume
|
| 113 |
+
- `DELETE /analyses/{id}` - Delete analysis
|
| 114 |
+
|
| 115 |
+
## π― Usage Workflow
|
| 116 |
+
|
| 117 |
+
1. **Upload Files**: Upload resume (PDF/DOCX) and job description
|
| 118 |
+
2. **Automatic Processing**: Files are processed and text extracted
|
| 119 |
+
3. **AI Analysis**: System calculates hard/soft match scores
|
| 120 |
+
4. **Results Display**: View detailed analysis with recommendations
|
| 121 |
+
5. **History Tracking**: All analyses are saved for future reference
|
| 122 |
+
|
| 123 |
+
## π Analysis Metrics
|
| 124 |
+
|
| 125 |
+
### Scoring System:
|
| 126 |
+
- **Hard Match (70% weight)**: Keyword-based matching using TF-IDF
|
| 127 |
+
- **Soft Match (30% weight)**: Semantic similarity using embeddings
|
| 128 |
+
- **Overall Score**: Weighted combination of hard and soft scores
|
| 129 |
+
- **Verdict**: High (β₯75%), Medium (50-74%), Low (<50%)
|
| 130 |
+
|
| 131 |
+
### Features:
|
| 132 |
+
- Missing skills identification
|
| 133 |
+
- Personalized feedback generation
|
| 134 |
+
- Skill gap analysis
|
| 135 |
+
- Industry-specific recommendations
|
| 136 |
+
|
| 137 |
+
## π Development Mode
|
| 138 |
+
|
| 139 |
+
### Hot Reload
|
| 140 |
+
The server runs in development mode with auto-reload enabled. Changes to Python files will automatically restart the server.
|
| 141 |
+
|
| 142 |
+
### Debug Mode
|
| 143 |
+
Add debug logging by setting:
|
| 144 |
+
```python
|
| 145 |
+
import logging
|
| 146 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
## π± Frontend Features
|
| 150 |
+
|
| 151 |
+
### Interactive UI:
|
| 152 |
+
- Real-time file upload with progress indication
|
| 153 |
+
- Animated score visualization
|
| 154 |
+
- Responsive design for mobile/desktop
|
| 155 |
+
- Search and filter capabilities
|
| 156 |
+
- Analysis history dashboard
|
| 157 |
+
|
| 158 |
+
### Modern Design:
|
| 159 |
+
- Gradient backgrounds and glassmorphism effects
|
| 160 |
+
- Smooth animations and transitions
|
| 161 |
+
- Intuitive user experience
|
| 162 |
+
- Professional styling
|
| 163 |
+
|
| 164 |
+
## π¨ Troubleshooting
|
| 165 |
+
|
| 166 |
+
### Common Issues:
|
| 167 |
+
|
| 168 |
+
1. **CORS Errors**: Make sure backend is running on port 8000
|
| 169 |
+
2. **File Upload Fails**: Check file format (PDF/DOCX only)
|
| 170 |
+
3. **Analysis Errors**: Verify both files are uploaded successfully
|
| 171 |
+
4. **Database Issues**: Delete `resume_analysis.db` to reset database
|
| 172 |
+
|
| 173 |
+
### Performance Optimization:
|
| 174 |
+
- Use PostgreSQL for production workloads
|
| 175 |
+
- Implement caching for frequently accessed analyses
|
| 176 |
+
- Add database indexing for large datasets
|
| 177 |
+
- Consider async processing for large files
|
| 178 |
+
|
| 179 |
+
## π Production Deployment
|
| 180 |
+
|
| 181 |
+
### Backend Deployment:
|
| 182 |
+
```bash
|
| 183 |
+
# Install production ASGI server
|
| 184 |
+
pip install gunicorn
|
| 185 |
+
|
| 186 |
+
# Run with Gunicorn
|
| 187 |
+
gunicorn server:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
|
| 188 |
+
```
|
| 189 |
+
|
| 190 |
+
### Frontend Deployment:
|
| 191 |
+
- Host the HTML file on any web server
|
| 192 |
+
- Update API_BASE_URL to production backend URL
|
| 193 |
+
- Consider using CDN for static assets
|
| 194 |
+
|
| 195 |
+
### Database Setup:
|
| 196 |
+
- Migrate to PostgreSQL for production
|
| 197 |
+
- Set up regular backups
|
| 198 |
+
- Implement connection pooling
|
| 199 |
+
- Add database monitoring
|
| 200 |
+
|
| 201 |
+
## π Success!
|
| 202 |
+
|
| 203 |
+
Your Resume Relevance Check System is now ready! The system provides:
|
| 204 |
+
|
| 205 |
+
β
**AI-Powered Analysis**: Advanced NLP for resume scoring
|
| 206 |
+
β
**Database Integration**: Persistent storage with SQLite/PostgreSQL
|
| 207 |
+
β
**RESTful API**: Clean, documented API endpoints
|
| 208 |
+
β
**Modern Frontend**: Responsive, interactive web interface
|
| 209 |
+
β
**Production Ready**: Scalable architecture for deployment
|
| 210 |
+
|
| 211 |
+
## π Support
|
| 212 |
+
|
| 213 |
+
For issues or questions:
|
| 214 |
+
1. Check the troubleshooting section
|
| 215 |
+
2. Verify all dependencies are installed correctly
|
| 216 |
+
3. Ensure the backend server is running on port 8000
|
| 217 |
+
4. Check browser console for any JavaScript errors
|
| 218 |
+
|
| 219 |
+
Happy analyzing! π
|
requirements.txt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# requirements.txt
|
| 2 |
+
fastapi==0.104.1
|
| 3 |
+
uvicorn==0.24.0
|
| 4 |
+
sqlalchemy==2.0.23
|
| 5 |
+
python-multipart==0.0.6
|
| 6 |
+
PyPDF2==3.0.1
|
| 7 |
+
# If PyPDF2 doesn't work, try:
|
| 8 |
+
# pypdf==4.0.1
|
| 9 |
+
# If you get Visual Studio Build Tools, you can use:
|
| 10 |
+
# PyMuPDF==1.23.8
|
| 11 |
+
python-docx==1.1.0
|
| 12 |
+
sentence-transformers==2.2.2
|
| 13 |
+
scikit-learn==1.3.2
|
| 14 |
+
python-dotenv==1.0.0
|
| 15 |
+
pydantic==2.5.0
|
| 16 |
+
aiofiles==23.2.1
|
| 17 |
+
spacy==3.7.2
|
resume_analysis.db
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0aafef76741ad76f87a6346d9e3567dabebb4d722f7cfa0c2b26edd3a650246
|
| 3 |
+
size 897024
|
run.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# run.py - Script to start the server
|
| 2 |
+
"""
|
| 3 |
+
Simple script to run the FastAPI server
|
| 4 |
+
Usage: python run.py
|
| 5 |
+
"""
|
| 6 |
+
import uvicorn
|
| 7 |
+
|
| 8 |
+
if __name__ == "__main__":
|
| 9 |
+
uvicorn.run(
|
| 10 |
+
"server:app",
|
| 11 |
+
host="127.0.0.1",
|
| 12 |
+
port=8000,
|
| 13 |
+
reload=True, # Enable auto-reload during development
|
| 14 |
+
log_level="info"
|
| 15 |
+
)
|
server.py
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# server.py - Updated with enhanced text processing
|
| 2 |
+
from fastapi import FastAPI, File, UploadFile, Depends, HTTPException, Form
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
+
from sqlalchemy.orm import Session
|
| 5 |
+
from typing import List
|
| 6 |
+
import json
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
|
| 9 |
+
from database import get_db, Resume, JobDescription, Analysis, ActivityLog
|
| 10 |
+
from models import AnalysisResponse, AnalysisResult
|
| 11 |
+
|
| 12 |
+
# Use the enhanced text processor
|
| 13 |
+
try:
|
| 14 |
+
from text_processor import EnhancedTextProcessor
|
| 15 |
+
text_processor = EnhancedTextProcessor()
|
| 16 |
+
print("β
Using Enhanced Text Processor with optimized skills matching")
|
| 17 |
+
except ImportError:
|
| 18 |
+
from text_processor import TextProcessor
|
| 19 |
+
text_processor = TextProcessor()
|
| 20 |
+
print("β οΈ Using Basic Text Processor")
|
| 21 |
+
|
| 22 |
+
app = FastAPI(
|
| 23 |
+
title="Resume Relevance Check API",
|
| 24 |
+
version="2.0.0",
|
| 25 |
+
description="AI-Powered Resume Analysis with Enhanced Matching"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Enable CORS for frontend integration
|
| 29 |
+
app.add_middleware(
|
| 30 |
+
CORSMiddleware,
|
| 31 |
+
allow_origins=["*"], # In production, specify your frontend URL
|
| 32 |
+
allow_credentials=True,
|
| 33 |
+
allow_methods=["*"],
|
| 34 |
+
allow_headers=["*"],
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
@app.on_event("startup")
|
| 38 |
+
async def startup_event():
|
| 39 |
+
print("π Resume Relevance Check API v2.0 is starting up...")
|
| 40 |
+
print(f"π PDF Library: {getattr(text_processor, 'PDF_LIBRARY', 'Unknown')}")
|
| 41 |
+
print(f"π§ Skills Database: {len(getattr(text_processor, 'technical_skills', []))} skills loaded")
|
| 42 |
+
|
| 43 |
+
@app.get("/")
|
| 44 |
+
async def root():
|
| 45 |
+
return {
|
| 46 |
+
"message": "Resume Relevance Check API v2.0",
|
| 47 |
+
"status": "running",
|
| 48 |
+
"features": ["Enhanced Skills Matching", "Multi-PDF Support", "Industry-Specific Analysis"],
|
| 49 |
+
"pdf_support": hasattr(text_processor, 'PDF_LIBRARY')
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
@app.post("/upload/resume/")
|
| 53 |
+
async def upload_resume(file: UploadFile = File(...), db: Session = Depends(get_db)):
|
| 54 |
+
"""Upload and process resume file with enhanced text extraction"""
|
| 55 |
+
|
| 56 |
+
# Validate file type
|
| 57 |
+
allowed_types = ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"]
|
| 58 |
+
if file.content_type not in allowed_types:
|
| 59 |
+
raise HTTPException(
|
| 60 |
+
status_code=400,
|
| 61 |
+
detail="Only PDF and DOCX files are supported. Please convert your file to one of these formats."
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
try:
|
| 65 |
+
# Read file content
|
| 66 |
+
file_content = await file.read()
|
| 67 |
+
|
| 68 |
+
# Extract text based on file type
|
| 69 |
+
if file.content_type == "application/pdf":
|
| 70 |
+
try:
|
| 71 |
+
extracted_text = text_processor.extract_text_from_pdf(file_content)
|
| 72 |
+
file_type = "pdf"
|
| 73 |
+
except Exception as pdf_error:
|
| 74 |
+
raise HTTPException(
|
| 75 |
+
status_code=500,
|
| 76 |
+
detail=f"PDF processing failed: {str(pdf_error)}. Please try converting to DOCX format."
|
| 77 |
+
)
|
| 78 |
+
else:
|
| 79 |
+
extracted_text = text_processor.extract_text_from_docx(file_content)
|
| 80 |
+
file_type = "docx"
|
| 81 |
+
|
| 82 |
+
# Validate extracted text
|
| 83 |
+
if not extracted_text or len(extracted_text.strip()) < 50:
|
| 84 |
+
raise HTTPException(
|
| 85 |
+
status_code=400,
|
| 86 |
+
detail="Could not extract sufficient text from the file. Please ensure the file contains readable text."
|
| 87 |
+
)
|
| 88 |
+
|
| 89 |
+
# Clean text with enhanced processing
|
| 90 |
+
cleaned_text = text_processor.clean_text(extracted_text)
|
| 91 |
+
|
| 92 |
+
# Extract skills for preview
|
| 93 |
+
if hasattr(text_processor, 'extract_skills_enhanced'):
|
| 94 |
+
skills_found = text_processor.extract_skills_enhanced(cleaned_text)
|
| 95 |
+
skills_preview = f" | Skills detected: {', '.join(skills_found[:5])}{'...' if len(skills_found) > 5 else ''}"
|
| 96 |
+
else:
|
| 97 |
+
skills_preview = ""
|
| 98 |
+
|
| 99 |
+
# Save to database
|
| 100 |
+
db_resume = Resume(
|
| 101 |
+
filename=file.filename,
|
| 102 |
+
file_type=file_type,
|
| 103 |
+
file_content=file_content,
|
| 104 |
+
extracted_text=cleaned_text
|
| 105 |
+
)
|
| 106 |
+
db.add(db_resume)
|
| 107 |
+
db.commit()
|
| 108 |
+
db.refresh(db_resume)
|
| 109 |
+
|
| 110 |
+
# Log activity with more details
|
| 111 |
+
log_entry = ActivityLog(
|
| 112 |
+
action="upload_resume",
|
| 113 |
+
details=f"Uploaded resume: {file.filename} | Type: {file_type} | Text length: {len(cleaned_text)} chars{skills_preview}"
|
| 114 |
+
)
|
| 115 |
+
db.add(log_entry)
|
| 116 |
+
db.commit()
|
| 117 |
+
|
| 118 |
+
# Create enhanced preview
|
| 119 |
+
preview_text = cleaned_text[:200] + "..." if len(cleaned_text) > 200 else cleaned_text
|
| 120 |
+
|
| 121 |
+
return {
|
| 122 |
+
"message": "Resume uploaded and processed successfully",
|
| 123 |
+
"resume_id": db_resume.id,
|
| 124 |
+
"filename": file.filename,
|
| 125 |
+
"file_type": file_type,
|
| 126 |
+
"extracted_text_preview": preview_text + skills_preview,
|
| 127 |
+
"text_length": len(cleaned_text),
|
| 128 |
+
"processing_status": "enhanced" if hasattr(text_processor, 'extract_skills_enhanced') else "basic"
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
except Exception as e:
|
| 132 |
+
raise HTTPException(status_code=500, detail=f"Error processing resume: {str(e)}")
|
| 133 |
+
|
| 134 |
+
@app.post("/upload/job-description/")
|
| 135 |
+
async def upload_job_description(file: UploadFile = File(...), db: Session = Depends(get_db)):
|
| 136 |
+
"""Upload and process job description file with enhanced text extraction"""
|
| 137 |
+
|
| 138 |
+
allowed_types = [
|
| 139 |
+
"application/pdf",
|
| 140 |
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 141 |
+
"text/plain"
|
| 142 |
+
]
|
| 143 |
+
if file.content_type not in allowed_types:
|
| 144 |
+
raise HTTPException(
|
| 145 |
+
status_code=400,
|
| 146 |
+
detail="Only PDF, DOCX, and TXT files are supported for job descriptions."
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
try:
|
| 150 |
+
# Read file content
|
| 151 |
+
file_content = await file.read()
|
| 152 |
+
|
| 153 |
+
# Extract text based on file type
|
| 154 |
+
if file.content_type == "application/pdf":
|
| 155 |
+
try:
|
| 156 |
+
extracted_text = text_processor.extract_text_from_pdf(file_content)
|
| 157 |
+
file_type = "pdf"
|
| 158 |
+
except Exception as pdf_error:
|
| 159 |
+
raise HTTPException(
|
| 160 |
+
status_code=500,
|
| 161 |
+
detail=f"PDF processing failed: {str(pdf_error)}. Please try converting to DOCX or TXT format."
|
| 162 |
+
)
|
| 163 |
+
elif file.content_type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
| 164 |
+
extracted_text = text_processor.extract_text_from_docx(file_content)
|
| 165 |
+
file_type = "docx"
|
| 166 |
+
else:
|
| 167 |
+
extracted_text = file_content.decode('utf-8')
|
| 168 |
+
file_type = "txt"
|
| 169 |
+
|
| 170 |
+
# Validate extracted text
|
| 171 |
+
if not extracted_text or len(extracted_text.strip()) < 30:
|
| 172 |
+
raise HTTPException(
|
| 173 |
+
status_code=400,
|
| 174 |
+
detail="Could not extract sufficient text from the job description. Please check the file content."
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
# Clean text with enhanced processing
|
| 178 |
+
cleaned_text = text_processor.clean_text(extracted_text)
|
| 179 |
+
|
| 180 |
+
# Extract required skills for preview
|
| 181 |
+
if hasattr(text_processor, 'extract_skills_enhanced'):
|
| 182 |
+
required_skills = text_processor.extract_skills_enhanced(cleaned_text)
|
| 183 |
+
skills_preview = f" | Required skills: {', '.join(required_skills[:5])}{'...' if len(required_skills) > 5 else ''}"
|
| 184 |
+
else:
|
| 185 |
+
skills_preview = ""
|
| 186 |
+
|
| 187 |
+
# Save to database
|
| 188 |
+
db_job = JobDescription(
|
| 189 |
+
filename=file.filename,
|
| 190 |
+
file_type=file_type,
|
| 191 |
+
file_content=file_content,
|
| 192 |
+
extracted_text=cleaned_text
|
| 193 |
+
)
|
| 194 |
+
db.add(db_job)
|
| 195 |
+
db.commit()
|
| 196 |
+
db.refresh(db_job)
|
| 197 |
+
|
| 198 |
+
# Log activity
|
| 199 |
+
log_entry = ActivityLog(
|
| 200 |
+
action="upload_job_description",
|
| 201 |
+
details=f"Uploaded job description: {file.filename} | Type: {file_type} | Text length: {len(cleaned_text)} chars{skills_preview}"
|
| 202 |
+
)
|
| 203 |
+
db.add(log_entry)
|
| 204 |
+
db.commit()
|
| 205 |
+
|
| 206 |
+
# Create enhanced preview
|
| 207 |
+
preview_text = cleaned_text[:200] + "..." if len(cleaned_text) > 200 else cleaned_text
|
| 208 |
+
|
| 209 |
+
return {
|
| 210 |
+
"message": "Job description uploaded and processed successfully",
|
| 211 |
+
"job_description_id": db_job.id,
|
| 212 |
+
"filename": file.filename,
|
| 213 |
+
"file_type": file_type,
|
| 214 |
+
"extracted_text_preview": preview_text + skills_preview,
|
| 215 |
+
"text_length": len(cleaned_text),
|
| 216 |
+
"processing_status": "enhanced" if hasattr(text_processor, 'extract_skills_enhanced') else "basic"
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
except Exception as e:
|
| 220 |
+
raise HTTPException(status_code=500, detail=f"Error processing job description: {str(e)}")
|
| 221 |
+
|
| 222 |
+
@app.post("/analyze/", response_model=AnalysisResponse)
|
| 223 |
+
async def analyze_resume(resume_id: int = Form(...), job_description_id: int = Form(...), db: Session = Depends(get_db)):
|
| 224 |
+
"""Analyze resume against job description with enhanced AI processing"""
|
| 225 |
+
|
| 226 |
+
# Get resume and job description from database
|
| 227 |
+
resume = db.query(Resume).filter(Resume.id == resume_id).first()
|
| 228 |
+
job_desc = db.query(JobDescription).filter(JobDescription.id == job_description_id).first()
|
| 229 |
+
|
| 230 |
+
if not resume or not job_desc:
|
| 231 |
+
raise HTTPException(status_code=404, detail="Resume or job description not found")
|
| 232 |
+
|
| 233 |
+
try:
|
| 234 |
+
# Use enhanced analysis if available
|
| 235 |
+
if hasattr(text_processor, 'calculate_enhanced_hard_score'):
|
| 236 |
+
print("π Running enhanced analysis...")
|
| 237 |
+
|
| 238 |
+
# Enhanced hard score calculation
|
| 239 |
+
hard_score, missing_skills = text_processor.calculate_enhanced_hard_score(
|
| 240 |
+
resume.extracted_text, job_desc.extracted_text
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
# Enhanced semantic similarity
|
| 244 |
+
soft_score = text_processor.calculate_semantic_score(
|
| 245 |
+
resume.extracted_text, job_desc.extracted_text
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
# Enhanced feedback generation
|
| 249 |
+
feedback = text_processor.generate_enhanced_feedback(
|
| 250 |
+
hard_score, soft_score, missing_skills,
|
| 251 |
+
resume.extracted_text, job_desc.extracted_text
|
| 252 |
+
)
|
| 253 |
+
else:
|
| 254 |
+
print("β οΈ Using basic analysis...")
|
| 255 |
+
|
| 256 |
+
# Fallback to basic analysis
|
| 257 |
+
hard_score, missing_skills = text_processor.calculate_hard_match_score(
|
| 258 |
+
resume.extracted_text, job_desc.extracted_text
|
| 259 |
+
)
|
| 260 |
+
soft_score = text_processor.calculate_soft_match_score(
|
| 261 |
+
resume.extracted_text, job_desc.extracted_text
|
| 262 |
+
)
|
| 263 |
+
feedback = text_processor.generate_feedback(hard_score, soft_score, missing_skills)
|
| 264 |
+
|
| 265 |
+
# Calculate overall score (70% hard, 30% soft)
|
| 266 |
+
overall_score = (hard_score * 0.7) + (soft_score * 0.3)
|
| 267 |
+
|
| 268 |
+
# Determine verdict with enhanced thresholds
|
| 269 |
+
if overall_score >= 75:
|
| 270 |
+
verdict = "High"
|
| 271 |
+
elif overall_score >= 50:
|
| 272 |
+
verdict = "Medium"
|
| 273 |
+
else:
|
| 274 |
+
verdict = "Low"
|
| 275 |
+
|
| 276 |
+
# Save analysis to database
|
| 277 |
+
db_analysis = Analysis(
|
| 278 |
+
resume_id=resume_id,
|
| 279 |
+
job_description_id=job_description_id,
|
| 280 |
+
hard_score=hard_score,
|
| 281 |
+
soft_score=soft_score,
|
| 282 |
+
overall_score=overall_score,
|
| 283 |
+
verdict=verdict,
|
| 284 |
+
missing_skills=json.dumps(missing_skills),
|
| 285 |
+
feedback=feedback
|
| 286 |
+
)
|
| 287 |
+
db.add(db_analysis)
|
| 288 |
+
db.commit()
|
| 289 |
+
|
| 290 |
+
# Log detailed analysis activity
|
| 291 |
+
log_entry = ActivityLog(
|
| 292 |
+
action="analyze",
|
| 293 |
+
details=f"Enhanced analysis completed | Resume: {resume.filename} vs Job: {job_desc.filename} | Score: {overall_score:.1f}% ({verdict}) | Missing skills: {len(missing_skills)}"
|
| 294 |
+
)
|
| 295 |
+
db.add(log_entry)
|
| 296 |
+
db.commit()
|
| 297 |
+
|
| 298 |
+
return AnalysisResponse(
|
| 299 |
+
hard_score=round(hard_score, 2),
|
| 300 |
+
soft_score=round(soft_score, 2),
|
| 301 |
+
overall_score=round(overall_score, 2),
|
| 302 |
+
verdict=verdict,
|
| 303 |
+
missing_skills=missing_skills,
|
| 304 |
+
feedback=feedback
|
| 305 |
+
)
|
| 306 |
+
|
| 307 |
+
except Exception as e:
|
| 308 |
+
raise HTTPException(status_code=500, detail=f"Error during enhanced analysis: {str(e)}")
|
| 309 |
+
|
| 310 |
+
@app.get("/analyses/", response_model=List[AnalysisResult])
|
| 311 |
+
async def get_analyses(db: Session = Depends(get_db), skip: int = 0, limit: int = 100):
|
| 312 |
+
"""Get analysis history with enhanced details"""
|
| 313 |
+
analyses = db.query(Analysis).join(Resume).offset(skip).limit(limit).all()
|
| 314 |
+
|
| 315 |
+
results = []
|
| 316 |
+
for analysis in analyses:
|
| 317 |
+
resume = db.query(Resume).filter(Resume.id == analysis.resume_id).first()
|
| 318 |
+
results.append(AnalysisResult(
|
| 319 |
+
id=analysis.id,
|
| 320 |
+
resume_filename=resume.filename,
|
| 321 |
+
hard_score=analysis.hard_score,
|
| 322 |
+
soft_score=analysis.soft_score,
|
| 323 |
+
overall_score=analysis.overall_score,
|
| 324 |
+
verdict=analysis.verdict,
|
| 325 |
+
missing_skills=json.loads(analysis.missing_skills),
|
| 326 |
+
feedback=analysis.feedback,
|
| 327 |
+
analysis_date=analysis.analysis_date
|
| 328 |
+
))
|
| 329 |
+
|
| 330 |
+
return results
|
| 331 |
+
|
| 332 |
+
@app.get("/analyses/{analysis_id}")
|
| 333 |
+
async def get_analysis_details(analysis_id: int, db: Session = Depends(get_db)):
|
| 334 |
+
"""Get detailed analysis by ID with enhanced information"""
|
| 335 |
+
analysis = db.query(Analysis).filter(Analysis.id == analysis_id).first()
|
| 336 |
+
if not analysis:
|
| 337 |
+
raise HTTPException(status_code=404, detail="Analysis not found")
|
| 338 |
+
|
| 339 |
+
resume = db.query(Resume).filter(Resume.id == analysis.resume_id).first()
|
| 340 |
+
job_desc = db.query(JobDescription).filter(JobDescription.id == analysis.job_description_id).first()
|
| 341 |
+
|
| 342 |
+
return {
|
| 343 |
+
"id": analysis.id,
|
| 344 |
+
"resume_filename": resume.filename,
|
| 345 |
+
"job_description_filename": job_desc.filename,
|
| 346 |
+
"hard_score": analysis.hard_score,
|
| 347 |
+
"soft_score": analysis.soft_score,
|
| 348 |
+
"overall_score": analysis.overall_score,
|
| 349 |
+
"verdict": analysis.verdict,
|
| 350 |
+
"missing_skills": json.loads(analysis.missing_skills),
|
| 351 |
+
"feedback": analysis.feedback,
|
| 352 |
+
"analysis_date": analysis.analysis_date,
|
| 353 |
+
"processing_type": "enhanced" if hasattr(text_processor, 'calculate_enhanced_hard_score') else "basic"
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
@app.get("/resumes/")
|
| 357 |
+
async def get_resumes(db: Session = Depends(get_db)):
|
| 358 |
+
"""Get all uploaded resumes with enhanced details"""
|
| 359 |
+
resumes = db.query(Resume).all()
|
| 360 |
+
return [
|
| 361 |
+
{
|
| 362 |
+
"id": r.id,
|
| 363 |
+
"filename": r.filename,
|
| 364 |
+
"file_type": r.file_type,
|
| 365 |
+
"upload_date": r.upload_date,
|
| 366 |
+
"text_length": len(r.extracted_text) if r.extracted_text else 0
|
| 367 |
+
} for r in resumes
|
| 368 |
+
]
|
| 369 |
+
|
| 370 |
+
@app.get("/job-descriptions/")
|
| 371 |
+
async def get_job_descriptions(db: Session = Depends(get_db)):
|
| 372 |
+
"""Get all uploaded job descriptions with enhanced details"""
|
| 373 |
+
job_descs = db.query(JobDescription).all()
|
| 374 |
+
return [
|
| 375 |
+
{
|
| 376 |
+
"id": j.id,
|
| 377 |
+
"filename": j.filename,
|
| 378 |
+
"file_type": j.file_type,
|
| 379 |
+
"upload_date": j.upload_date,
|
| 380 |
+
"text_length": len(j.extracted_text) if j.extracted_text else 0
|
| 381 |
+
} for j in job_descs
|
| 382 |
+
]
|
| 383 |
+
|
| 384 |
+
@app.get("/system/status")
|
| 385 |
+
async def get_system_status():
|
| 386 |
+
"""Get system status and capabilities"""
|
| 387 |
+
return {
|
| 388 |
+
"api_version": "2.0.0",
|
| 389 |
+
"enhanced_processing": hasattr(text_processor, 'calculate_enhanced_hard_score'),
|
| 390 |
+
"pdf_support": hasattr(text_processor, 'extract_text_from_pdf'),
|
| 391 |
+
"pdf_library": getattr(text_processor, 'PDF_LIBRARY', 'None'),
|
| 392 |
+
"skills_database_size": len(getattr(text_processor, 'technical_skills', [])),
|
| 393 |
+
"supported_formats": ["PDF", "DOCX", "TXT"],
|
| 394 |
+
"features": [
|
| 395 |
+
"Enhanced Skills Matching",
|
| 396 |
+
"Industry-Specific Analysis",
|
| 397 |
+
"Multi-Library PDF Support",
|
| 398 |
+
"Semantic Similarity Analysis",
|
| 399 |
+
"Personalized Feedback Generation"
|
| 400 |
+
]
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
@app.delete("/resumes/{resume_id}")
|
| 404 |
+
async def delete_resume(resume_id: int, db: Session = Depends(get_db)):
|
| 405 |
+
"""Delete a resume and associated analyses"""
|
| 406 |
+
resume = db.query(Resume).filter(Resume.id == resume_id).first()
|
| 407 |
+
if not resume:
|
| 408 |
+
raise HTTPException(status_code=404, detail="Resume not found")
|
| 409 |
+
|
| 410 |
+
# Delete associated analyses
|
| 411 |
+
db.query(Analysis).filter(Analysis.resume_id == resume_id).delete()
|
| 412 |
+
|
| 413 |
+
# Delete resume
|
| 414 |
+
db.delete(resume)
|
| 415 |
+
db.commit()
|
| 416 |
+
|
| 417 |
+
# Log deletion
|
| 418 |
+
log_entry = ActivityLog(
|
| 419 |
+
action="delete_resume",
|
| 420 |
+
details=f"Deleted resume: {resume.filename} and associated analyses"
|
| 421 |
+
)
|
| 422 |
+
db.add(log_entry)
|
| 423 |
+
db.commit()
|
| 424 |
+
|
| 425 |
+
return {"message": "Resume and associated analyses deleted successfully"}
|
| 426 |
+
|
| 427 |
+
@app.delete("/analyses/{analysis_id}")
|
| 428 |
+
async def delete_analysis(analysis_id: int, db: Session = Depends(get_db)):
|
| 429 |
+
"""Delete a specific analysis"""
|
| 430 |
+
analysis = db.query(Analysis).filter(Analysis.id == analysis_id).first()
|
| 431 |
+
if not analysis:
|
| 432 |
+
raise HTTPException(status_code=404, detail="Analysis not found")
|
| 433 |
+
|
| 434 |
+
db.delete(analysis)
|
| 435 |
+
db.commit()
|
| 436 |
+
|
| 437 |
+
# Log deletion
|
| 438 |
+
log_entry = ActivityLog(
|
| 439 |
+
action="delete_analysis",
|
| 440 |
+
details=f"Deleted analysis ID: {analysis_id}"
|
| 441 |
+
)
|
| 442 |
+
db.add(log_entry)
|
| 443 |
+
db.commit()
|
| 444 |
+
|
| 445 |
+
return {"message": "Analysis deleted successfully"}
|
| 446 |
+
|
| 447 |
+
@app.get("/analytics/summary")
|
| 448 |
+
async def get_analytics_summary(db: Session = Depends(get_db)):
|
| 449 |
+
"""Get system usage analytics"""
|
| 450 |
+
total_resumes = db.query(Resume).count()
|
| 451 |
+
total_job_descriptions = db.query(JobDescription).count()
|
| 452 |
+
total_analyses = db.query(Analysis).count()
|
| 453 |
+
|
| 454 |
+
# Verdict distribution
|
| 455 |
+
verdicts = db.query(Analysis.verdict).all()
|
| 456 |
+
verdict_counts = {"High": 0, "Medium": 0, "Low": 0}
|
| 457 |
+
for (verdict,) in verdicts:
|
| 458 |
+
if verdict in verdict_counts:
|
| 459 |
+
verdict_counts[verdict] += 1
|
| 460 |
+
|
| 461 |
+
# Average scores
|
| 462 |
+
scores = db.query(Analysis.overall_score).all()
|
| 463 |
+
avg_score = sum(score[0] for score in scores) / len(scores) if scores else 0
|
| 464 |
+
|
| 465 |
+
return {
|
| 466 |
+
"total_resumes": total_resumes,
|
| 467 |
+
"total_job_descriptions": total_job_descriptions,
|
| 468 |
+
"total_analyses": total_analyses,
|
| 469 |
+
"verdict_distribution": verdict_counts,
|
| 470 |
+
"average_score": round(avg_score, 2),
|
| 471 |
+
"processing_type": "enhanced" if hasattr(text_processor, 'calculate_enhanced_hard_score') else "basic"
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
if __name__ == "__main__":
|
| 475 |
+
import uvicorn
|
| 476 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
setup.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# setup.py - Installation script
|
| 2 |
+
"""
|
| 3 |
+
Setup script for installing required packages
|
| 4 |
+
Usage: python setup.py
|
| 5 |
+
"""
|
| 6 |
+
import subprocess
|
| 7 |
+
import sys
|
| 8 |
+
|
| 9 |
+
def install_requirements():
|
| 10 |
+
"""Install required packages"""
|
| 11 |
+
requirements = [
|
| 12 |
+
"fastapi==0.104.1",
|
| 13 |
+
"uvicorn==0.24.0",
|
| 14 |
+
"sqlalchemy==2.0.23",
|
| 15 |
+
"python-multipart==0.0.6",
|
| 16 |
+
"PyMuPDF==1.23.8",
|
| 17 |
+
"python-docx==1.1.0",
|
| 18 |
+
"sentence-transformers==2.2.2",
|
| 19 |
+
"scikit-learn==1.3.2",
|
| 20 |
+
"python-dotenv==1.0.0",
|
| 21 |
+
"pydantic==2.5.0",
|
| 22 |
+
"aiofiles==23.2.1"
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
+
for requirement in requirements:
|
| 26 |
+
try:
|
| 27 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", requirement])
|
| 28 |
+
print(f"β Installed {requirement}")
|
| 29 |
+
except subprocess.CalledProcessError:
|
| 30 |
+
print(f"β Failed to install {requirement}")
|
| 31 |
+
|
| 32 |
+
def install_spacy_model():
|
| 33 |
+
"""Install spaCy English model"""
|
| 34 |
+
try:
|
| 35 |
+
subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
|
| 36 |
+
print("β Installed spaCy English model")
|
| 37 |
+
except subprocess.CalledProcessError:
|
| 38 |
+
print("β Failed to install spaCy model (optional)")
|
| 39 |
+
|
| 40 |
+
if __name__ == "__main__":
|
| 41 |
+
print("Installing Resume Relevance Check System dependencies...")
|
| 42 |
+
install_requirements()
|
| 43 |
+
install_spacy_model()
|
| 44 |
+
print("\nπ Setup complete! Run 'python run.py' to start the server.")
|
smart_setup.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# smart_setup.py - Intelligent installation script
|
| 2 |
+
import subprocess
|
| 3 |
+
import sys
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
def install_package(package_name):
|
| 7 |
+
"""Install a package using pip"""
|
| 8 |
+
try:
|
| 9 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
|
| 10 |
+
return True
|
| 11 |
+
except subprocess.CalledProcessError:
|
| 12 |
+
return False
|
| 13 |
+
|
| 14 |
+
def test_pdf_libraries():
|
| 15 |
+
"""Test which PDF library works"""
|
| 16 |
+
pdf_libraries = [
|
| 17 |
+
("PyPDF2==3.0.1", "PyPDF2", "from PyPDF2 import PdfReader"),
|
| 18 |
+
("pypdf==4.0.1", "pypdf", "import pypdf"),
|
| 19 |
+
("PyMuPDF==1.23.8", "PyMuPDF/fitz", "import fitz")
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
for package, name, test_import in pdf_libraries:
|
| 23 |
+
print(f"π Trying {name}...")
|
| 24 |
+
|
| 25 |
+
# Install the package
|
| 26 |
+
if install_package(package):
|
| 27 |
+
# Test if it imports successfully
|
| 28 |
+
try:
|
| 29 |
+
exec(test_import)
|
| 30 |
+
print(f"β
{name} installed and working!")
|
| 31 |
+
return name
|
| 32 |
+
except ImportError as e:
|
| 33 |
+
print(f"β {name} installed but not working: {e}")
|
| 34 |
+
continue
|
| 35 |
+
else:
|
| 36 |
+
print(f"β Failed to install {name}")
|
| 37 |
+
|
| 38 |
+
return None
|
| 39 |
+
|
| 40 |
+
def main():
|
| 41 |
+
print("π Smart Resume Relevance System Setup")
|
| 42 |
+
print("=" * 50)
|
| 43 |
+
|
| 44 |
+
# Core packages that should always work
|
| 45 |
+
core_packages = [
|
| 46 |
+
"fastapi==0.104.1",
|
| 47 |
+
"uvicorn==0.24.0",
|
| 48 |
+
"sqlalchemy==2.0.23",
|
| 49 |
+
"python-multipart==0.0.6",
|
| 50 |
+
"python-docx==1.1.0",
|
| 51 |
+
"sentence-transformers==2.2.2",
|
| 52 |
+
"scikit-learn==1.3.2",
|
| 53 |
+
"python-dotenv==1.0.0",
|
| 54 |
+
"pydantic==2.5.0",
|
| 55 |
+
"aiofiles==23.2.1"
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
print("π¦ Installing core packages...")
|
| 59 |
+
failed_packages = []
|
| 60 |
+
|
| 61 |
+
for package in core_packages:
|
| 62 |
+
package_name = package.split('==')[0]
|
| 63 |
+
print(f" Installing {package_name}...")
|
| 64 |
+
|
| 65 |
+
if install_package(package):
|
| 66 |
+
print(f" β
{package_name} installed successfully")
|
| 67 |
+
else:
|
| 68 |
+
print(f" β Failed to install {package_name}")
|
| 69 |
+
failed_packages.append(package_name)
|
| 70 |
+
|
| 71 |
+
print(f"\nπ Installing PDF processing library...")
|
| 72 |
+
pdf_library = test_pdf_libraries()
|
| 73 |
+
|
| 74 |
+
# Optional packages
|
| 75 |
+
print(f"\nπ― Installing optional packages...")
|
| 76 |
+
optional_packages = [
|
| 77 |
+
("spacy", "Better NLP processing (optional)")
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
for package, description in optional_packages:
|
| 81 |
+
print(f" Installing {package} - {description}")
|
| 82 |
+
if install_package(package):
|
| 83 |
+
print(f" β
{package} installed")
|
| 84 |
+
|
| 85 |
+
# Install spacy model if spacy was installed
|
| 86 |
+
if package == "spacy":
|
| 87 |
+
print(" π Installing spaCy English model...")
|
| 88 |
+
try:
|
| 89 |
+
subprocess.check_call([sys.executable, "-m", "spacy", "download", "en_core_web_sm"])
|
| 90 |
+
print(" β
spaCy model installed")
|
| 91 |
+
except subprocess.CalledProcessError:
|
| 92 |
+
print(" β οΈ spaCy model installation failed (optional)")
|
| 93 |
+
else:
|
| 94 |
+
print(f" β οΈ {package} installation failed (optional)")
|
| 95 |
+
|
| 96 |
+
# Summary
|
| 97 |
+
print(f"\nπ Setup Summary")
|
| 98 |
+
print("=" * 30)
|
| 99 |
+
|
| 100 |
+
if failed_packages:
|
| 101 |
+
print(f"β Failed core packages: {', '.join(failed_packages)}")
|
| 102 |
+
print("β οΈ System may not work properly without these packages")
|
| 103 |
+
else:
|
| 104 |
+
print("β
All core packages installed successfully")
|
| 105 |
+
|
| 106 |
+
if pdf_library:
|
| 107 |
+
print(f"β
PDF support: {pdf_library}")
|
| 108 |
+
else:
|
| 109 |
+
print("β No PDF library could be installed")
|
| 110 |
+
print("π You can still use DOCX and TXT files")
|
| 111 |
+
|
| 112 |
+
print(f"\nπ Next steps:")
|
| 113 |
+
if not failed_packages and pdf_library:
|
| 114 |
+
print("1. Run: python run.py")
|
| 115 |
+
print("2. Open frontend/index.html in your browser")
|
| 116 |
+
print("3. Upload some resumes and job descriptions!")
|
| 117 |
+
else:
|
| 118 |
+
print("1. Fix any failed package installations")
|
| 119 |
+
print("2. For PDF issues, try installing Visual Studio Build Tools")
|
| 120 |
+
print("3. Alternatively, use DOCX format for documents")
|
| 121 |
+
|
| 122 |
+
# Create a status file
|
| 123 |
+
status = {
|
| 124 |
+
"core_packages_ok": len(failed_packages) == 0,
|
| 125 |
+
"pdf_library": pdf_library,
|
| 126 |
+
"ready_to_run": len(failed_packages) == 0,
|
| 127 |
+
"supported_formats": ["DOCX", "TXT"] + (["PDF"] if pdf_library else [])
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
print(f"\nπΎ Installation status saved to setup_status.txt")
|
| 131 |
+
with open("setup_status.txt", "w") as f:
|
| 132 |
+
f.write("Resume Relevance System Setup Status\n")
|
| 133 |
+
f.write("=" * 40 + "\n")
|
| 134 |
+
f.write(f"Core packages: {'β
OK' if status['core_packages_ok'] else 'β Failed'}\n")
|
| 135 |
+
f.write(f"PDF support: {'β
' + pdf_library if pdf_library else 'β None'}\n")
|
| 136 |
+
f.write(f"Ready to run: {'β
Yes' if status['ready_to_run'] else 'β No'}\n")
|
| 137 |
+
f.write(f"Supported formats: {', '.join(status['supported_formats'])}\n")
|
| 138 |
+
|
| 139 |
+
if __name__ == "__main__":
|
| 140 |
+
main()
|
text_processor.py
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# optimized_text_processor.py
|
| 2 |
+
import re
|
| 3 |
+
from typing import List, Tuple, Dict, Set
|
| 4 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
| 5 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
| 6 |
+
from sentence_transformers import SentenceTransformer
|
| 7 |
+
import json
|
| 8 |
+
|
| 9 |
+
# Alternative PDF processing options
|
| 10 |
+
try:
|
| 11 |
+
import fitz # PyMuPDF
|
| 12 |
+
PDF_LIBRARY = "pymupdf"
|
| 13 |
+
except ImportError:
|
| 14 |
+
try:
|
| 15 |
+
from PyPDF2 import PdfReader
|
| 16 |
+
PDF_LIBRARY = "pypdf2"
|
| 17 |
+
except ImportError:
|
| 18 |
+
try:
|
| 19 |
+
import pypdf
|
| 20 |
+
PDF_LIBRARY = "pypdf"
|
| 21 |
+
except ImportError:
|
| 22 |
+
PDF_LIBRARY = None
|
| 23 |
+
|
| 24 |
+
from docx import Document
|
| 25 |
+
import spacy
|
| 26 |
+
|
| 27 |
+
class EnhancedTextProcessor:
|
| 28 |
+
def __init__(self):
|
| 29 |
+
# Load pre-trained models
|
| 30 |
+
self.sentence_model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 31 |
+
|
| 32 |
+
# Try to load spaCy model
|
| 33 |
+
try:
|
| 34 |
+
self.nlp = spacy.load("en_core_web_sm")
|
| 35 |
+
except OSError:
|
| 36 |
+
print("Warning: spaCy model not found. Using basic processing.")
|
| 37 |
+
self.nlp = None
|
| 38 |
+
|
| 39 |
+
# Enhanced skills database based on your sample documents
|
| 40 |
+
self.technical_skills = {
|
| 41 |
+
# Programming Languages
|
| 42 |
+
'python', 'sql', 'r', 'java', 'javascript', 'c++', 'c#', 'scala', 'matlab',
|
| 43 |
+
|
| 44 |
+
# Python Libraries (from your resume)
|
| 45 |
+
'pandas', 'numpy', 'matplotlib', 'seaborn', 'scikit-learn', 'scipy',
|
| 46 |
+
'beautiful soup', 'requests', 'regex', 'plotly', 'streamlit', 'flask', 'django',
|
| 47 |
+
|
| 48 |
+
# Databases
|
| 49 |
+
'mysql', 'postgresql', 'mongodb', 'sqlite', 'oracle', 'sql server',
|
| 50 |
+
|
| 51 |
+
# Data Tools
|
| 52 |
+
'power bi', 'tableau', 'excel', 'pivot tables', 'dax', 'power query',
|
| 53 |
+
'jupyter', 'google analytics', 'looker', 'qlik',
|
| 54 |
+
|
| 55 |
+
# Cloud & Big Data
|
| 56 |
+
'aws', 'azure', 'gcp', 'spark', 'hadoop', 'kafka', 'airflow',
|
| 57 |
+
'snowflake', 'redshift', 'bigquery',
|
| 58 |
+
|
| 59 |
+
# AI/ML (from job description)
|
| 60 |
+
'machine learning', 'deep learning', 'nlp', 'llm', 'generative ai',
|
| 61 |
+
'tensorflow', 'pytorch', 'keras', 'transformers', 'bert', 'gpt',
|
| 62 |
+
|
| 63 |
+
# Manufacturing/Engineering (from job description)
|
| 64 |
+
'manufacturing', 'production', 'automotive', 'aerospace', 'mechanical engineering',
|
| 65 |
+
'quality control', 'lean manufacturing', 'six sigma', 'process optimization',
|
| 66 |
+
|
| 67 |
+
# Data Analysis
|
| 68 |
+
'statistics', 'statistical analysis', 'hypothesis testing', 'correlation analysis',
|
| 69 |
+
'descriptive statistics', 'data visualization', 'eda', 'exploratory data analysis',
|
| 70 |
+
'data cleaning', 'data transformation', 'data mining', 'predictive modeling',
|
| 71 |
+
|
| 72 |
+
# Business Intelligence
|
| 73 |
+
'kpi', 'dashboard', 'reporting', 'business intelligence', 'data warehousing',
|
| 74 |
+
'etl', 'data modeling', 'olap',
|
| 75 |
+
|
| 76 |
+
# Soft Skills
|
| 77 |
+
'problem solving', 'critical thinking', 'collaboration', 'communication',
|
| 78 |
+
'project management', 'stakeholder management', 'agile', 'scrum'
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
# Industry-specific keywords for better matching
|
| 82 |
+
self.domain_keywords = {
|
| 83 |
+
'data_analysis': ['analysis', 'insights', 'trends', 'patterns', 'metrics', 'kpi'],
|
| 84 |
+
'manufacturing': ['production', 'quality', 'process', 'automation', 'efficiency'],
|
| 85 |
+
'ai_ml': ['artificial intelligence', 'machine learning', 'model', 'algorithm'],
|
| 86 |
+
'business': ['stakeholder', 'business value', 'roi', 'optimization', 'strategy']
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
def extract_text_from_pdf(self, file_content: bytes) -> str:
|
| 90 |
+
"""Enhanced PDF text extraction with multiple library support"""
|
| 91 |
+
try:
|
| 92 |
+
if PDF_LIBRARY == "pymupdf":
|
| 93 |
+
return self._extract_with_pymupdf(file_content)
|
| 94 |
+
elif PDF_LIBRARY == "pypdf2":
|
| 95 |
+
return self._extract_with_pypdf2(file_content)
|
| 96 |
+
elif PDF_LIBRARY == "pypdf":
|
| 97 |
+
return self._extract_with_pypdf(file_content)
|
| 98 |
+
else:
|
| 99 |
+
raise Exception("No PDF library available. Please install PyMuPDF or PyPDF2.")
|
| 100 |
+
except Exception as e:
|
| 101 |
+
raise Exception(f"Error extracting PDF text: {str(e)}")
|
| 102 |
+
|
| 103 |
+
def _extract_with_pymupdf(self, file_content: bytes) -> str:
|
| 104 |
+
"""Extract text using PyMuPDF (fitz)"""
|
| 105 |
+
doc = fitz.open(stream=file_content, filetype="pdf")
|
| 106 |
+
text = ""
|
| 107 |
+
for page in doc:
|
| 108 |
+
text += page.get_text()
|
| 109 |
+
doc.close()
|
| 110 |
+
return text
|
| 111 |
+
|
| 112 |
+
def _extract_with_pypdf2(self, file_content: bytes) -> str:
|
| 113 |
+
"""Extract text using PyPDF2"""
|
| 114 |
+
from io import BytesIO
|
| 115 |
+
pdf_reader = PdfReader(BytesIO(file_content))
|
| 116 |
+
text = ""
|
| 117 |
+
for page in pdf_reader.pages:
|
| 118 |
+
text += page.extract_text()
|
| 119 |
+
return text
|
| 120 |
+
|
| 121 |
+
def _extract_with_pypdf(self, file_content: bytes) -> str:
|
| 122 |
+
"""Extract text using pypdf"""
|
| 123 |
+
from io import BytesIO
|
| 124 |
+
import pypdf
|
| 125 |
+
pdf_reader = pypdf.PdfReader(BytesIO(file_content))
|
| 126 |
+
text = ""
|
| 127 |
+
for page in pdf_reader.pages:
|
| 128 |
+
text += page.extract_text()
|
| 129 |
+
return text
|
| 130 |
+
|
| 131 |
+
def extract_text_from_docx(self, file_content: bytes) -> str:
|
| 132 |
+
"""Extract text from DOCX file"""
|
| 133 |
+
try:
|
| 134 |
+
from io import BytesIO
|
| 135 |
+
doc = Document(BytesIO(file_content))
|
| 136 |
+
text = ""
|
| 137 |
+
for paragraph in doc.paragraphs:
|
| 138 |
+
text += paragraph.text + "\n"
|
| 139 |
+
|
| 140 |
+
# Also extract text from tables
|
| 141 |
+
for table in doc.tables:
|
| 142 |
+
for row in table.rows:
|
| 143 |
+
for cell in row.cells:
|
| 144 |
+
text += cell.text + " "
|
| 145 |
+
text += "\n"
|
| 146 |
+
|
| 147 |
+
return text
|
| 148 |
+
except Exception as e:
|
| 149 |
+
raise Exception(f"Error extracting DOCX text: {str(e)}")
|
| 150 |
+
|
| 151 |
+
def clean_text(self, text: str) -> str:
|
| 152 |
+
"""Enhanced text cleaning and normalization"""
|
| 153 |
+
# Remove extra whitespace and normalize
|
| 154 |
+
text = re.sub(r'\s+', ' ', text)
|
| 155 |
+
text = text.strip()
|
| 156 |
+
|
| 157 |
+
# Handle common PDF extraction issues
|
| 158 |
+
text = re.sub(r'[^\w\s\.\,\:\;\-\(\)\[\]\/\+\@]', ' ', text)
|
| 159 |
+
|
| 160 |
+
# Normalize common variations
|
| 161 |
+
text = re.sub(r'\bPython\b', 'python', text, flags=re.IGNORECASE)
|
| 162 |
+
text = re.sub(r'\bSQL\b', 'sql', text, flags=re.IGNORECASE)
|
| 163 |
+
text = re.sub(r'\bPower\s*BI\b', 'power bi', text, flags=re.IGNORECASE)
|
| 164 |
+
text = re.sub(r'\bMachine\s*Learning\b', 'machine learning', text, flags=re.IGNORECASE)
|
| 165 |
+
|
| 166 |
+
return text.lower()
|
| 167 |
+
|
| 168 |
+
def extract_skills_enhanced(self, text: str) -> List[str]:
|
| 169 |
+
"""Enhanced skill extraction with better matching"""
|
| 170 |
+
text_lower = text.lower()
|
| 171 |
+
found_skills = []
|
| 172 |
+
|
| 173 |
+
# Direct skill matching
|
| 174 |
+
for skill in self.technical_skills:
|
| 175 |
+
# Use word boundaries for better matching
|
| 176 |
+
skill_pattern = r'\b' + re.escape(skill.lower()) + r'\b'
|
| 177 |
+
if re.search(skill_pattern, text_lower):
|
| 178 |
+
found_skills.append(skill.title())
|
| 179 |
+
|
| 180 |
+
# Extract programming languages with special patterns
|
| 181 |
+
prog_patterns = {
|
| 182 |
+
'Python': r'\bpython\b|\bpandas\b|\bnumpy\b|\bmatplotlib\b',
|
| 183 |
+
'SQL': r'\bsql\b|\bmysql\b|\bpostgresql\b|\bquery\b|\bqueries\b',
|
| 184 |
+
'R': r'\br\b(?!\w)', # R as standalone word
|
| 185 |
+
'Excel': r'\bexcel\b|\bpivot\s*table\b|\bvlookup\b',
|
| 186 |
+
'Power BI': r'\bpower\s*bi\b|\bdax\b|\bpower\s*query\b'
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
for skill, pattern in prog_patterns.items():
|
| 190 |
+
if re.search(pattern, text_lower, re.IGNORECASE):
|
| 191 |
+
found_skills.append(skill)
|
| 192 |
+
|
| 193 |
+
# Remove duplicates while preserving order
|
| 194 |
+
return list(dict.fromkeys(found_skills))
|
| 195 |
+
|
| 196 |
+
def calculate_enhanced_hard_score(self, resume_text: str, job_text: str) -> Tuple[float, List[str]]:
|
| 197 |
+
"""Enhanced hard matching with better keyword analysis"""
|
| 198 |
+
|
| 199 |
+
# Extract skills from both texts
|
| 200 |
+
resume_skills = set(skill.lower() for skill in self.extract_skills_enhanced(resume_text))
|
| 201 |
+
job_skills = set(skill.lower() for skill in self.extract_skills_enhanced(job_text))
|
| 202 |
+
|
| 203 |
+
# Calculate skill-based score
|
| 204 |
+
if not job_skills:
|
| 205 |
+
skill_score = 50.0 # Default score if no skills detected
|
| 206 |
+
else:
|
| 207 |
+
overlap = len(resume_skills.intersection(job_skills))
|
| 208 |
+
skill_score = (overlap / len(job_skills)) * 100
|
| 209 |
+
|
| 210 |
+
# TF-IDF based matching for additional context
|
| 211 |
+
try:
|
| 212 |
+
# Create custom vocabulary focused on technical terms
|
| 213 |
+
vectorizer = TfidfVectorizer(
|
| 214 |
+
stop_words='english',
|
| 215 |
+
max_features=1000,
|
| 216 |
+
ngram_range=(1, 2), # Include bigrams
|
| 217 |
+
min_df=1
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
tfidf_matrix = vectorizer.fit_transform([resume_text, job_text])
|
| 221 |
+
cosine_sim = cosine_similarity(tfidf_matrix[0:1], tfidf_matrix[1:2])[0][0]
|
| 222 |
+
tfidf_score = cosine_sim * 100
|
| 223 |
+
|
| 224 |
+
# Weighted combination (60% skills, 40% TF-IDF)
|
| 225 |
+
combined_score = (skill_score * 0.6) + (tfidf_score * 0.4)
|
| 226 |
+
except:
|
| 227 |
+
combined_score = skill_score
|
| 228 |
+
|
| 229 |
+
# Find missing critical skills
|
| 230 |
+
missing_skills = list(job_skills - resume_skills)
|
| 231 |
+
|
| 232 |
+
# Prioritize missing skills based on frequency in job description
|
| 233 |
+
prioritized_missing = []
|
| 234 |
+
job_text_lower = job_text.lower()
|
| 235 |
+
|
| 236 |
+
for skill in missing_skills:
|
| 237 |
+
skill_count = len(re.findall(r'\b' + re.escape(skill) + r'\b', job_text_lower))
|
| 238 |
+
prioritized_missing.append((skill, skill_count))
|
| 239 |
+
|
| 240 |
+
# Sort by frequency and take top skills
|
| 241 |
+
prioritized_missing.sort(key=lambda x: x[1], reverse=True)
|
| 242 |
+
final_missing_skills = [skill.title() for skill, _ in prioritized_missing[:8]]
|
| 243 |
+
|
| 244 |
+
return min(combined_score, 100.0), final_missing_skills
|
| 245 |
+
|
| 246 |
+
def calculate_semantic_score(self, resume_text: str, job_text: str) -> float:
|
| 247 |
+
"""Enhanced semantic similarity calculation"""
|
| 248 |
+
try:
|
| 249 |
+
# Split longer texts into chunks for better processing
|
| 250 |
+
resume_chunks = self._split_text(resume_text, max_length=500)
|
| 251 |
+
job_chunks = self._split_text(job_text, max_length=500)
|
| 252 |
+
|
| 253 |
+
# Calculate embeddings for chunks
|
| 254 |
+
resume_embeddings = self.sentence_model.encode(resume_chunks)
|
| 255 |
+
job_embeddings = self.sentence_model.encode(job_chunks)
|
| 256 |
+
|
| 257 |
+
# Find best matching chunks
|
| 258 |
+
similarities = []
|
| 259 |
+
for job_emb in job_embeddings:
|
| 260 |
+
chunk_similarities = cosine_similarity([job_emb], resume_embeddings)[0]
|
| 261 |
+
similarities.append(max(chunk_similarities))
|
| 262 |
+
|
| 263 |
+
# Average similarity across all job chunks
|
| 264 |
+
avg_similarity = sum(similarities) / len(similarities)
|
| 265 |
+
|
| 266 |
+
return min(avg_similarity * 100, 100.0)
|
| 267 |
+
|
| 268 |
+
except Exception as e:
|
| 269 |
+
print(f"Error calculating semantic similarity: {e}")
|
| 270 |
+
# Fallback to simple word overlap
|
| 271 |
+
return self._simple_word_overlap(resume_text, job_text)
|
| 272 |
+
|
| 273 |
+
def _split_text(self, text: str, max_length: int = 500) -> List[str]:
|
| 274 |
+
"""Split text into meaningful chunks"""
|
| 275 |
+
sentences = re.split(r'[.!?]+', text)
|
| 276 |
+
chunks = []
|
| 277 |
+
current_chunk = ""
|
| 278 |
+
|
| 279 |
+
for sentence in sentences:
|
| 280 |
+
sentence = sentence.strip()
|
| 281 |
+
if len(current_chunk) + len(sentence) < max_length:
|
| 282 |
+
current_chunk += sentence + ". "
|
| 283 |
+
else:
|
| 284 |
+
if current_chunk:
|
| 285 |
+
chunks.append(current_chunk.strip())
|
| 286 |
+
current_chunk = sentence + ". "
|
| 287 |
+
|
| 288 |
+
if current_chunk:
|
| 289 |
+
chunks.append(current_chunk.strip())
|
| 290 |
+
|
| 291 |
+
return chunks if chunks else [text[:max_length]]
|
| 292 |
+
|
| 293 |
+
def _simple_word_overlap(self, text1: str, text2: str) -> float:
|
| 294 |
+
"""Simple word overlap fallback"""
|
| 295 |
+
words1 = set(re.findall(r'\b\w+\b', text1.lower()))
|
| 296 |
+
words2 = set(re.findall(r'\b\w+\b', text2.lower()))
|
| 297 |
+
|
| 298 |
+
if not words2:
|
| 299 |
+
return 0.0
|
| 300 |
+
|
| 301 |
+
overlap = len(words1.intersection(words2))
|
| 302 |
+
return (overlap / len(words2)) * 100
|
| 303 |
+
|
| 304 |
+
def generate_enhanced_feedback(self, hard_score: float, soft_score: float,
|
| 305 |
+
missing_skills: List[str], resume_text: str, job_text: str) -> str:
|
| 306 |
+
"""Generate comprehensive, personalized feedback"""
|
| 307 |
+
|
| 308 |
+
feedback_parts = []
|
| 309 |
+
|
| 310 |
+
# Overall assessment
|
| 311 |
+
overall_score = (hard_score * 0.7) + (soft_score * 0.3)
|
| 312 |
+
|
| 313 |
+
if overall_score >= 80:
|
| 314 |
+
feedback_parts.append("π― Excellent match! Your profile strongly aligns with this role.")
|
| 315 |
+
elif overall_score >= 65:
|
| 316 |
+
feedback_parts.append("β
Good match! You have most of the required qualifications.")
|
| 317 |
+
elif overall_score >= 45:
|
| 318 |
+
feedback_parts.append("β οΈ Moderate match. Consider highlighting relevant experience more prominently.")
|
| 319 |
+
else:
|
| 320 |
+
feedback_parts.append("π This role requires significant skill development to be a strong match.")
|
| 321 |
+
|
| 322 |
+
# Technical skills assessment
|
| 323 |
+
if hard_score >= 70:
|
| 324 |
+
feedback_parts.append("Your technical skills are well-aligned with the requirements.")
|
| 325 |
+
elif hard_score >= 40:
|
| 326 |
+
feedback_parts.append("You have some relevant technical skills, but there are gaps to address.")
|
| 327 |
+
else:
|
| 328 |
+
feedback_parts.append("Focus on developing the core technical skills for this role.")
|
| 329 |
+
|
| 330 |
+
# Semantic alignment
|
| 331 |
+
if soft_score >= 70:
|
| 332 |
+
feedback_parts.append("Your experience narrative aligns well with the job context.")
|
| 333 |
+
else:
|
| 334 |
+
feedback_parts.append("Consider restructuring your resume to better reflect the job's language and requirements.")
|
| 335 |
+
|
| 336 |
+
# Missing skills guidance
|
| 337 |
+
if missing_skills:
|
| 338 |
+
critical_skills = missing_skills[:3] # Top 3 most important
|
| 339 |
+
if len(critical_skills) == 1:
|
| 340 |
+
feedback_parts.append(f"Priority skill to develop: {critical_skills[0]}.")
|
| 341 |
+
else:
|
| 342 |
+
feedback_parts.append(f"Priority skills to develop: {', '.join(critical_skills[:-1])}, and {critical_skills[-1]}.")
|
| 343 |
+
|
| 344 |
+
if len(missing_skills) > 3:
|
| 345 |
+
feedback_parts.append(f"Additional skills to consider: {', '.join(missing_skills[3:6])}.")
|
| 346 |
+
|
| 347 |
+
# Industry-specific advice based on job content
|
| 348 |
+
job_lower = job_text.lower()
|
| 349 |
+
if 'manufacturing' in job_lower or 'production' in job_lower:
|
| 350 |
+
feedback_parts.append("π‘ For manufacturing roles, emphasize process improvement and data-driven optimization experience.")
|
| 351 |
+
|
| 352 |
+
if 'machine learning' in job_lower or 'ai' in job_lower:
|
| 353 |
+
feedback_parts.append("π€ Highlight any AI/ML projects, even academic ones, and consider showcasing model deployment experience.")
|
| 354 |
+
|
| 355 |
+
if 'stakeholder' in job_lower or 'business' in job_lower:
|
| 356 |
+
feedback_parts.append("π₯ Emphasize your ability to translate technical insights into business value and stakeholder communication.")
|
| 357 |
+
|
| 358 |
+
# Action items
|
| 359 |
+
if overall_score < 60:
|
| 360 |
+
feedback_parts.append("π Recommended actions: Update your skills section, add relevant projects, and use keywords from the job description.")
|
| 361 |
+
|
| 362 |
+
return " ".join(feedback_parts)
|
| 363 |
+
|
| 364 |
+
# Keep the old method names for compatibility
|
| 365 |
+
def calculate_hard_match_score(self, resume_text: str, job_text: str) -> Tuple[float, List[str]]:
|
| 366 |
+
"""Compatibility wrapper for enhanced hard matching"""
|
| 367 |
+
return self.calculate_enhanced_hard_score(resume_text, job_text)
|
| 368 |
+
|
| 369 |
+
def calculate_soft_match_score(self, resume_text: str, job_text: str) -> float:
|
| 370 |
+
"""Compatibility wrapper for semantic scoring"""
|
| 371 |
+
return self.calculate_semantic_score(resume_text, job_text)
|
| 372 |
+
|
| 373 |
+
def generate_feedback(self, hard_score: float, soft_score: float, missing_skills: List[str]) -> str:
|
| 374 |
+
"""Compatibility wrapper - simplified version"""
|
| 375 |
+
return self.generate_enhanced_feedback(hard_score, soft_score, missing_skills, "", "")
|