Anushkabhat9 commited on
Commit
c77ff37
·
verified ·
1 Parent(s): 344cbc3

Update similarity_score_refined.py

Browse files
Files changed (1) hide show
  1. similarity_score_refined.py +6 -7
similarity_score_refined.py CHANGED
@@ -60,7 +60,7 @@ def similarity_main(tailored_resume, job_description):
60
  - job_description (str): Job description content.
61
 
62
  Returns:
63
- - dict: A dictionary containing the 'score' and 'reason'.
64
  """
65
  prompt = f"""
66
  You are a recruitment expert evaluating how well a tailored resume aligns with a job description. Provide a realistic and concise evaluation based on the following criteria:
@@ -68,16 +68,13 @@ You are a recruitment expert evaluating how well a tailored resume aligns with a
68
  2. Domain Match: Are the candidate's experiences and achievements relevant to the industry or role?
69
  3. Clarity and Conciseness: Is the resume well-structured and focused on the job requirements?
70
  4. Highlight any gaps or mismatched qualifications realistically.
71
-
72
  Provide your response in this exact format:
73
  Score: [Score between 0 and 1]
74
  Reason: [One or two sentences explaining the score]
75
-
76
  Here is the tailored resume:
77
  [Resume Start]
78
  {tailored_resume}
79
  [Resume End]
80
-
81
  And the job description below:
82
  [Job Description Start]
83
  {job_description}
@@ -93,16 +90,17 @@ And the job description below:
93
 
94
  # Extract content text
95
  content_text = candidates[0].content.parts[0].text
 
96
 
97
  # Extract score and reason with simple parsing
98
  lines = content_text.split("\n")
99
  score = None
100
  reason = None
101
- print(content_text)
102
  for line in lines:
103
  if line.lower().startswith("score:"):
104
  try:
105
- score = float(line.split(":", 1)[1].strip())*100
106
  except ValueError:
107
  raise ValueError(f"Invalid score format: {line}")
108
  elif line.lower().startswith("reason:"):
@@ -114,8 +112,9 @@ And the job description below:
114
  if not reason:
115
  reason = "No reason provided."
116
 
117
- return score
118
 
119
  except Exception as e:
120
  print(f"Error in relevance checking: {e}")
121
  return None
 
 
60
  - job_description (str): Job description content.
61
 
62
  Returns:
63
+ - dict: A dictionary containing the 'score' (scaled to 0–100) and 'reason'.
64
  """
65
  prompt = f"""
66
  You are a recruitment expert evaluating how well a tailored resume aligns with a job description. Provide a realistic and concise evaluation based on the following criteria:
 
68
  2. Domain Match: Are the candidate's experiences and achievements relevant to the industry or role?
69
  3. Clarity and Conciseness: Is the resume well-structured and focused on the job requirements?
70
  4. Highlight any gaps or mismatched qualifications realistically.
 
71
  Provide your response in this exact format:
72
  Score: [Score between 0 and 1]
73
  Reason: [One or two sentences explaining the score]
 
74
  Here is the tailored resume:
75
  [Resume Start]
76
  {tailored_resume}
77
  [Resume End]
 
78
  And the job description below:
79
  [Job Description Start]
80
  {job_description}
 
90
 
91
  # Extract content text
92
  content_text = candidates[0].content.parts[0].text
93
+ print(f"Response from Gemini Pro:\n{content_text}") # Debugging
94
 
95
  # Extract score and reason with simple parsing
96
  lines = content_text.split("\n")
97
  score = None
98
  reason = None
99
+
100
  for line in lines:
101
  if line.lower().startswith("score:"):
102
  try:
103
+ score = float(line.split(":", 1)[1].strip()) * 100 # Scale to 0–100
104
  except ValueError:
105
  raise ValueError(f"Invalid score format: {line}")
106
  elif line.lower().startswith("reason:"):
 
112
  if not reason:
113
  reason = "No reason provided."
114
 
115
+ return {"score": score, "reason": reason}
116
 
117
  except Exception as e:
118
  print(f"Error in relevance checking: {e}")
119
  return None
120
+