Imaginephoenix commited on
Commit
e1f904b
·
verified ·
1 Parent(s): b8ddc44

Update graders.py

Browse files
Files changed (1) hide show
  1. graders.py +7 -2
graders.py CHANGED
@@ -14,6 +14,11 @@ ROUTE_ALIAS_MAP = {
14
 
15
  SCORE_EPSILON = 1e-6
16
 
 
 
 
 
 
17
  def _clip_score(score_value: float) -> float:
18
  """Clip a score to the strict range (0.0, 1.0).
19
 
@@ -108,7 +113,7 @@ def _summary_keyword_score(summary_text: str, ground_truth: dict) -> float:
108
  """
109
  raw_keywords = ground_truth.get("summary_keywords", [])
110
  if not isinstance(raw_keywords, list):
111
- return 1.0 if len(summary_text.strip()) >= 10 else 0.0
112
 
113
  keywords = [
114
  _normalized_text(str(keyword))
@@ -116,7 +121,7 @@ def _summary_keyword_score(summary_text: str, ground_truth: dict) -> float:
116
  if _normalized_text(str(keyword))
117
  ]
118
  if not keywords:
119
- return 1.0 if len(summary_text.strip()) >= 10 else 0.0
120
 
121
  normalized_summary = _normalized_text(summary_text)
122
  matches = 0
 
14
 
15
  SCORE_EPSILON = 1e-6
16
 
17
+ def _strict_binary_score(is_positive_case: bool) -> float:
18
+ """Return strict in-range score for binary outcomes."""
19
+ return 1.0 - SCORE_EPSILON if is_positive_case else SCORE_EPSILON
20
+
21
+
22
  def _clip_score(score_value: float) -> float:
23
  """Clip a score to the strict range (0.0, 1.0).
24
 
 
113
  """
114
  raw_keywords = ground_truth.get("summary_keywords", [])
115
  if not isinstance(raw_keywords, list):
116
+ return _strict_binary_score(len(summary_text.strip()) >= 10)
117
 
118
  keywords = [
119
  _normalized_text(str(keyword))
 
121
  if _normalized_text(str(keyword))
122
  ]
123
  if not keywords:
124
+ return _strict_binary_score(len(summary_text.strip()) >= 10)
125
 
126
  normalized_summary = _normalized_text(summary_text)
127
  matches = 0