Zekun Wu commited on
Commit
90c9f9c
1 Parent(s): 8a0a737
Files changed (1) hide show
  1. util/evaluator.py +16 -2
util/evaluator.py CHANGED
@@ -9,9 +9,23 @@ class evaluator:
9
 
10
  def validate_scores(self, scores):
11
  required_keys = ["Factually Correct", "Useful", "Context Specific", "User Specific", "Provides Pluralism"]
 
12
  for key in required_keys:
13
- if key not in scores or not isinstance(scores[key], (int, float)) or not (-1 <= scores[key] <= 1):
14
- return {"Factually Correct": -1,"Useful": -1,"Context Specific": -1,"User Specific":-1,"Provides Pluralism":-1}
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  return scores
17
 
 
9
 
10
  def validate_scores(self, scores):
11
  required_keys = ["Factually Correct", "Useful", "Context Specific", "User Specific", "Provides Pluralism"]
12
+
13
  for key in required_keys:
14
+ if key not in scores:
15
+ return {k: {"Score": -1, "Justification": "Invalid input"} for k in required_keys}
16
+
17
+ score_data = scores[key]
18
+
19
+ if not isinstance(score_data, dict):
20
+ return {k: {"Score": -1, "Justification": "Invalid input format"} for k in required_keys}
21
+
22
+ if "Score" not in score_data or not isinstance(score_data["Score"], (int, float)) or not (
23
+ 0 <= score_data["Score"] <= 1):
24
+ return {k: {"Score": -1, "Justification": "Invalid score value"} for k in required_keys}
25
+
26
+ if "Justification" not in score_data or not isinstance(score_data["Justification"], str) or not score_data[
27
+ "Justification"].strip():
28
+ return {k: {"Score": -1, "Justification": "Invalid or missing justification"} for k in required_keys}
29
 
30
  return scores
31