jijihuny commited on
Commit
b2d3b4e
1 Parent(s): 6b67ae8
Files changed (1) hide show
  1. ecqa.py +3 -0
ecqa.py CHANGED
@@ -137,6 +137,9 @@ class ecqa(evaluate.Metric):
137
 
138
  true_positive = Counter(predictied_chars) & Counter(referenced_chars)
139
  n_true_positive = sum(true_positive.values())
 
 
 
140
  precision = 1.0 * n_true_positive / len(predictied_chars)
141
  recall = 1.0 * n_true_positive / len(referenced_chars)
142
  f1 = (2 * precision * recall) / (precision + recall)
 
137
 
138
  true_positive = Counter(predictied_chars) & Counter(referenced_chars)
139
  n_true_positive = sum(true_positive.values())
140
+ if n_true_positive == 0:
141
+ return 0, 0, 0
142
+
143
  precision = 1.0 * n_true_positive / len(predictied_chars)
144
  recall = 1.0 * n_true_positive / len(referenced_chars)
145
  f1 = (2 * precision * recall) / (precision + recall)