Repository navigation
Expand file tree
/
Copy pathtest_advanced_features.py
More file actions
334 lines (285 loc) Β· 12.3 KB
/
Copy pathtest_advanced_features.py
File metadata and controls
334 lines (285 loc) Β· 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
#!/usr/bin/env python3
"""
Test advanced features: Priority-based ranking, Trie search, and real data extraction
"""
from simple_job_search import SimpleJobSearch
from datetime import datetime
import os
def test_priority_ranking():
"""Test priority-based job ranking with max-heap"""
print("=" * 70)
print("π§ͺ TEST 1: Priority-Based Job Ranking with Max-Heap")
print("=" * 70)
searcher = SimpleJobSearch()
# Create sample jobs with varying attributes
sample_jobs = [
{
'title': 'Senior Python Developer',
'company': 'Google',
'location': 'Bangalore',
'experience': '3-5 years',
'salary': 'βΉ25-35 Lakh PA',
'description': 'Apply by 15/10/2025. 200 applicants. Python, Django, AWS required.',
'skills': ['python', 'django', 'aws'],
'source': 'LinkedIn'
},
{
'title': 'Software Engineer',
'company': 'Startup XYZ',
'location': 'Remote',
'experience': '2-4 years',
'salary': 'βΉ8-12 Lakh PA',
'description': 'Urgent hiring! Apply by 12/10/2025. 50 applicants.',
'skills': ['javascript', 'react'],
'source': 'TimesJobs'
},
{
'title': 'Full Stack Developer',
'company': 'Microsoft',
'location': 'Hyderabad',
'experience': '4-6 years',
'salary': 'βΉ30-40 Lakh PA',
'description': 'Great opportunity. 500 applicants.',
'skills': ['python', 'react', 'node.js'],
'source': 'LinkedIn'
},
{
'title': 'Backend Developer',
'company': 'TCS',
'location': 'Mumbai',
'experience': '2-3 years',
'salary': 'βΉ6-9 Lakh PA',
'description': 'Apply by 20/10/2025. 300 applicants.',
'skills': ['java', 'spring'],
'source': 'TimesJobs'
}
]
print(f"\nπ Testing with {len(sample_jobs)} sample jobs\n")
# Rank jobs using priority heap
ranked_jobs = searcher.rank_jobs_with_heap(sample_jobs)
print("π Jobs Ranked by Priority Score:")
print("-" * 70)
for i, job in enumerate(ranked_jobs, 1):
score = job.get('priority_score', 0)
salary_val = searcher.extract_salary_value(job['salary'])
revenue_score = searcher.get_company_revenue_score(job['company'])
applicants = searcher.extract_applicant_count(job)
print(f"\n{i}. {job['title']} at {job['company']}")
print(f" β Priority Score: {score:.2f}")
print(f" π° Salary: {job['salary']} (normalized: {salary_val:.0f}k)")
print(f" π’ Company Revenue Score: {revenue_score:.1f}/100")
print(f" π₯ Applicants: {applicants}")
print(f" π Location: {job['location']}")
print("\nβ
Priority ranking test completed!")
return ranked_jobs
def test_trie_and_inverted_index():
"""Test Trie-based autocomplete and inverted index search"""
print("\n" + "=" * 70)
print("π§ͺ TEST 2: Trie Autocomplete & Inverted Index Search")
print("=" * 70)
searcher = SimpleJobSearch()
# Sample jobs for indexing
jobs = [
{
'title': 'Python Developer',
'company': 'TechCorp',
'location': 'Bangalore',
'skills': ['python', 'django', 'postgresql'],
'description': 'Backend development with Python and Django',
'salary': 'βΉ10-15 LPA',
'experience': '2-4 years',
'source': 'LinkedIn'
},
{
'title': 'Data Scientist',
'company': 'DataCo',
'location': 'Mumbai',
'skills': ['python', 'machine learning', 'tensorflow'],
'description': 'Machine learning and data analysis',
'salary': 'βΉ15-20 LPA',
'experience': '3-5 years',
'source': 'TimesJobs'
},
{
'title': 'Frontend Developer',
'company': 'WebSoft',
'location': 'Remote',
'skills': ['javascript', 'react', 'css'],
'description': 'React and JavaScript development',
'salary': 'βΉ8-12 LPA',
'experience': '2-3 years',
'source': 'LinkedIn'
},
{
'title': 'Full Stack Python Developer',
'company': 'StartupXYZ',
'location': 'Bangalore',
'skills': ['python', 'react', 'mongodb'],
'description': 'Full stack development with Python backend',
'salary': 'βΉ12-18 LPA',
'experience': '3-5 years',
'source': 'TimesJobs'
}
]
print(f"\nπ Building search index for {len(jobs)} jobs...")
searcher.build_search_index(jobs)
print("β
Index built successfully!")
# Test autocomplete
print("\nπ€ Testing Autocomplete:")
print("-" * 70)
test_prefixes = ['pyt', 'dev', 'mach', 'ban']
for prefix in test_prefixes:
suggestions = searcher.trie.autocomplete(prefix, max_results=5)
print(f" '{prefix}' β {suggestions[:5]}")
# Test multi-keyword search
print("\nπ Testing Multi-Keyword Search:")
print("-" * 70)
test_queries = [
'python bangalore',
'react developer',
'machine learning',
'python react'
]
for query in test_queries:
results = searcher.fast_keyword_search(query)
print(f"\n Query: '{query}'")
print(f" Found {len(results)} matching jobs:")
for job in results:
print(f" β’ {job['title']} at {job['company']}")
print("\nβ
Trie and inverted index test completed!")
def test_real_data_extraction():
"""Test extraction of real data: salary, revenue, applicants, deadlines"""
print("\n" + "=" * 70)
print("π§ͺ TEST 3: Real Data Extraction")
print("=" * 70)
searcher = SimpleJobSearch()
# Test salary extraction
print("\nπ° Testing Salary Extraction:")
print("-" * 70)
salary_tests = [
'βΉ10-15 Lakh PA',
'$80k - $120k',
'βΉ8 LPA',
'Not disclosed',
'$100,000 - $150,000'
]
for salary_str in salary_tests:
value = searcher.extract_salary_value(salary_str)
print(f" '{salary_str}' β {value:.0f}k")
# Test company revenue scoring
print("\nπ’ Testing Company Revenue Scoring:")
print("-" * 70)
companies = ['Google', 'Microsoft', 'TCS', 'Infosys', 'Unknown Startup', 'Amazon']
for company in companies:
score = searcher.get_company_revenue_score(company)
print(f" {company:20s} β Revenue Score: {score:.1f}/100")
# Test applicant count extraction
print("\nπ₯ Testing Applicant Count Extraction:")
print("-" * 70)
job_samples = [
{'company': 'Google', 'description': '250 applicants have applied'},
{'company': 'TCS', 'description': 'Join our team'},
{'company': 'Microsoft', 'description': '500 people applied'},
{'company': 'Startup', 'description': 'Great opportunity'}
]
for job in job_samples:
count = searcher.extract_applicant_count(job)
print(f" {job['company']:15s} β {count} applicants (estimated)")
# Test deadline extraction and urgency
print("\nβ° Testing Deadline & Urgency Calculation:")
print("-" * 70)
deadline_samples = [
'Apply by 15/10/2025',
'Deadline: 20/11/2025',
'Last date 10/10/2025',
'No deadline mentioned'
]
for desc in deadline_samples:
job = {'description': desc}
deadline = searcher.extract_deadline(job)
urgency = searcher.calculate_urgency_score(deadline)
if deadline:
days_left = (deadline - datetime.now()).days
print(f" '{desc}' β {deadline.strftime('%d/%m/%Y')} ({days_left} days) β Urgency: {urgency:.3f}")
else:
print(f" '{desc}' β No deadline β Urgency: {urgency:.3f}")
print("\nβ
Real data extraction test completed!")
def test_complete_workflow_with_resume():
"""Test complete workflow with resume matching and priority ranking"""
print("\n" + "=" * 70)
print("π§ͺ TEST 4: Complete Workflow with Resume Matching")
print("=" * 70)
searcher = SimpleJobSearch()
# Check if sample resume exists
resume_file = 'sample_resume.docx'
if not os.path.exists(resume_file):
print(f"\nβ οΈ Sample resume not found. Creating one...")
os.system('python test_resume_sample.py')
if os.path.exists(resume_file):
print(f"\nπ Parsing resume: {resume_file}")
resume_data = searcher.parse_resume(resume_file)
if 'error' not in resume_data:
print(f"β
Resume parsed successfully!")
print(f" Skills: {len(resume_data['skills'])} found")
print(f" Experience: {resume_data['experience_years']} years")
print(f" Education: {resume_data['education']}")
# Extract job title from resume
job_title = searcher.extract_job_title_from_resume(resume_data)
print(f"\nπ€ Auto-extracted job title: '{job_title}'")
# Search jobs
print(f"\nπ Searching for jobs...")
jobs = searcher.search_jobs(job_title, "India")
if jobs:
print(f"β
Found {len(jobs)} jobs")
# Rank with resume matching + priority scoring
print(f"\nπ Ranking jobs with AI matching + priority scoring...")
ranked_jobs = searcher.rank_jobs_by_resume(jobs, resume_data)
# Show top 3
print(f"\nπ Top 3 Recommended Jobs:")
print("-" * 70)
for i, job in enumerate(ranked_jobs[:3], 1):
print(f"\n{i}. {job['title']} at {job['company']}")
print(f" β Priority Score: {job.get('priority_score', 0):.2f}")
print(f" π€ Resume Match: {job.get('match_score', 0):.1f}% ({job.get('match_category', 'N/A')})")
print(f" π° Salary: {job['salary']}")
print(f" π Location: {job['location']}")
if job.get('match_breakdown'):
skills_match = job['match_breakdown'].get('skills', {})
if skills_match.get('matching'):
print(f" β
Matching skills: {', '.join(skills_match['matching'][:5])}")
print("\nβ
Complete workflow test passed!")
else:
print("β οΈ No jobs found in search")
else:
print(f"β Error parsing resume: {resume_data['error']}")
else:
print(f"β Could not create sample resume")
def main():
"""Run all tests"""
print("\n" + "=" * 70)
print("π ADVANCED JOB SEARCH - COMPREHENSIVE TEST SUITE")
print("=" * 70)
try:
# Test 1: Priority ranking
test_priority_ranking()
# Test 2: Trie and inverted index
test_trie_and_inverted_index()
# Test 3: Real data extraction
test_real_data_extraction()
# Test 4: Complete workflow
test_complete_workflow_with_resume()
print("\n" + "=" * 70)
print("β
ALL TESTS COMPLETED SUCCESSFULLY!")
print("=" * 70)
print("\nπ Summary:")
print(" β Priority-based ranking with max-heap")
print(" β Trie autocomplete and fast keyword search")
print(" β Real data extraction (salary, revenue, applicants, deadlines)")
print(" β Resume matching with intelligent ranking")
print("\nπ Your job search system is production-ready!")
except Exception as e:
print(f"\nβ Test failed with error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()