WebashalarForML commited on
Commit
254bebc
·
verified ·
1 Parent(s): 0b573f9

Update utils/mistral.py

Browse files
Files changed (1) hide show
  1. utils/mistral.py +28 -19
utils/mistral.py CHANGED
@@ -370,6 +370,15 @@ def extract_link_details(text):
370
  links_RE = [link for link in links_RE if not any(email in link for email in emails)]
371
 
372
  return links_RE
 
 
 
 
 
 
 
 
 
373
 
374
  def process_resume_data(file_path):
375
  resume_text, hyperlinks = extract_text_based_on_format(file_path)
@@ -410,33 +419,33 @@ def process_resume_data(file_path):
410
  # Combine both personal and professional details into a structured output
411
  result = {
412
  "personal": {
413
- "name": per_data.get('personal', {}).get('name', None),
414
- "contact": per_data.get('personal', {}).get('contact_number', None),
415
- "email": per_data.get('personal', {}).get('email', None),
416
- "location": per_data.get('personal', {}).get('address', None),
417
- "linkedin": linkedin_links,
418
- "github": github_links,
419
- "other_links": hyperlinks # Store remaining links if needed
420
  },
421
  "professional": {
422
- "technical_skills": pro_data.get('professional', {}).get('technical_skills', None),
423
- "non_technical_skills": pro_data.get('professional', {}).get('non_technical_skills', None),
424
- "tools": pro_data.get('professional', {}).get('tools', None),
425
  "experience": [
426
  {
427
- "company": pro_data.get('professional', {}).get('companies_worked_at', None),
428
- "projects": pro_data.get('professional', {}).get('projects', None),
429
- "role": pro_data.get('professional', {}).get('roles', None),
430
- "years": pro_data.get('professional', {}).get('experience', None),
431
- "project_experience": pro_data.get('professional', {}).get('projects_experience', None)
432
  }
433
  ],
434
  "education": [
435
  {
436
- "qualification": Edu_data.get('educational', {}).get('qualifications', None),
437
- "university": Edu_data.get('educational', {}).get('university', None),
438
- "course": Edu_data.get('educational', {}).get('courses', None),
439
- "certificate": Edu_data.get('educational', {}).get('certifications', None)
440
  }
441
  ]
442
  }
 
370
  links_RE = [link for link in links_RE if not any(email in link for email in emails)]
371
 
372
  return links_RE
373
+
374
+ # For handling multiple data
375
+ def normalize_data(value):
376
+ """Replace empty lists with None and convert strings to lists."""
377
+ if value == []:
378
+ return None
379
+ elif isinstance(value, str):
380
+ return [value]
381
+ return value
382
 
383
  def process_resume_data(file_path):
384
  resume_text, hyperlinks = extract_text_based_on_format(file_path)
 
419
  # Combine both personal and professional details into a structured output
420
  result = {
421
  "personal": {
422
+ "name": normalize_data(per_data.get('personal', {}).get('name', None)),
423
+ "contact": normalize_data(per_data.get('personal', {}).get('contact_number', None)),
424
+ "email": normalize_data(per_data.get('personal', {}).get('email', None)),
425
+ "location": normalize_data(per_data.get('personal', {}).get('address', None)),
426
+ "linkedin": normalize_data(linkedin_links),
427
+ "github": normalize_data(github_links),
428
+ "other_links": normalize_data(hyperlinks)
429
  },
430
  "professional": {
431
+ "technical_skills": normalize_data(pro_data.get('professional', {}).get('technical_skills', None)),
432
+ "non_technical_skills": normalize_data(pro_data.get('professional', {}).get('non_technical_skills', None)),
433
+ "tools": normalize_data(pro_data.get('professional', {}).get('tools', None)),
434
  "experience": [
435
  {
436
+ "company": normalize_data(pro_data.get('professional', {}).get('companies_worked_at', None)),
437
+ "projects": normalize_data(pro_data.get('professional', {}).get('projects', None)),
438
+ "role": normalize_data(pro_data.get('professional', {}).get('roles', None)),
439
+ "years": normalize_data(pro_data.get('professional', {}).get('experience', None)),
440
+ "project_experience": normalize_data(pro_data.get('professional', {}).get('projects_experience', None))
441
  }
442
  ],
443
  "education": [
444
  {
445
+ "qualification": normalize_data(Edu_data.get('educational', {}).get('qualifications', None)),
446
+ "university": normalize_data(Edu_data.get('educational', {}).get('university', None)),
447
+ "course": normalize_data(Edu_data.get('educational', {}).get('courses', None)),
448
+ "certificate": normalize_data(Edu_data.get('educational', {}).get('certifications', None))
449
  }
450
  ]
451
  }