ShubhamD95 commited on
Commit
38b8d8b
·
verified ·
1 Parent(s): 749f56d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -21,14 +21,30 @@ def highlight_keywords(resume_text, matched):
21
  highlighted = re.sub(rf"\b({re.escape(word)})\b", r"**\1**", highlighted, flags=re.IGNORECASE)
22
  return highlighted
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  # 🔍 Prompt for dynamic section classification and feedback
25
  def build_dynamic_prompt(job_desc, resume_text, analyze_with_jd):
26
  prompt = f"""
27
  You are an expert resume analyst.
28
  Classify the content of the resume into meaningful categories based on the text (e.g., Technical Skills, Soft Skills, Certifications, Projects, Work Experience, Education, Personal Information).
29
-
30
  You do not need a fixed list of section names—choose the most suitable ones based on the content.
31
-
32
  Then:
33
  - For each section, summarize its contents.
34
  - If a job description is provided, compare each section against it.
@@ -52,9 +68,10 @@ def analyze_resume(job_desc, resume_text, analyze_with_jd):
52
  response = summarizer(user_prompt, max_new_tokens=768, do_sample=True, temperature=0.7)[0]['generated_text']
53
  cleaned = re.sub(rf".*?{re.escape(resume_text)}", "", response, flags=re.DOTALL).strip()
54
  if analyze_with_jd and job_desc:
55
- matched, missing = compare_keywords(resume_text, job_desc)
56
  highlighted_resume = highlight_keywords(resume_text, matched)
57
- return f"### 🔍 Resume with Highlighted Matches\n\n{highlighted_resume}\n\n---\n**✅ Matched Keywords:** {', '.join(sorted(matched)) or 'None'}\n\n**❌ Missing Keywords from Resume:** {', '.join(sorted(missing)) or 'None'}\n\n---\n{cleaned}"
 
58
  return cleaned
59
  except Exception as e:
60
  return f"❌ Error: {str(e)}"
@@ -76,4 +93,4 @@ def create_ui():
76
  return demo
77
 
78
  if __name__ == '__main__':
79
- create_ui().launch()
 
21
  highlighted = re.sub(rf"\b({re.escape(word)})\b", r"**\1**", highlighted, flags=re.IGNORECASE)
22
  return highlighted
23
 
24
+ # 🔍 Use LLM to extract missing keywords contextually from JD
25
+ def extract_missing_keywords_with_llm(job_desc, resume_text):
26
+ prompt = f"""
27
+ You are an expert resume evaluator.
28
+
29
+ Given the job description and the resume, identify important skills, tools, and concepts in the job description that are missing or weakly represented in the resume.
30
+
31
+ List only the missing or insufficiently addressed keywords in bullet format.
32
+
33
+ Job Description:
34
+ {job_desc}
35
+
36
+ Resume:
37
+ {resume_text}
38
+ """
39
+ result = summarizer(prompt, max_new_tokens=300, do_sample=True, temperature=0.7)[0]['generated_text']
40
+ return result.strip()
41
+
42
  # 🔍 Prompt for dynamic section classification and feedback
43
  def build_dynamic_prompt(job_desc, resume_text, analyze_with_jd):
44
  prompt = f"""
45
  You are an expert resume analyst.
46
  Classify the content of the resume into meaningful categories based on the text (e.g., Technical Skills, Soft Skills, Certifications, Projects, Work Experience, Education, Personal Information).
 
47
  You do not need a fixed list of section names—choose the most suitable ones based on the content.
 
48
  Then:
49
  - For each section, summarize its contents.
50
  - If a job description is provided, compare each section against it.
 
68
  response = summarizer(user_prompt, max_new_tokens=768, do_sample=True, temperature=0.7)[0]['generated_text']
69
  cleaned = re.sub(rf".*?{re.escape(resume_text)}", "", response, flags=re.DOTALL).strip()
70
  if analyze_with_jd and job_desc:
71
+ matched, _ = compare_keywords(resume_text, job_desc)
72
  highlighted_resume = highlight_keywords(resume_text, matched)
73
+ llm_missing_keywords = extract_missing_keywords_with_llm(job_desc, resume_text)
74
+ return f"### 🔍 Resume with Highlighted Matches\n\n{highlighted_resume}\n\n---\n**✅ Matched Keywords:** {', '.join(sorted(matched)) or 'None'}\n\n**❌ LLM-Inferred Missing Keywords:**\n{llm_missing_keywords}\n\n---\n{cleaned}"
75
  return cleaned
76
  except Exception as e:
77
  return f"❌ Error: {str(e)}"
 
93
  return demo
94
 
95
  if __name__ == '__main__':
96
+ create_ui().launch()