samuelam commited on
Commit
cff7419
1 Parent(s): 90a7ae2

Update evaluation/evaluator.py

Browse files
Files changed (1) hide show
  1. evaluation/evaluator.py +16 -1
evaluation/evaluator.py CHANGED
@@ -1,6 +1,17 @@
1
  import json
2
  from evaluation.evaluate_utils.evaluate_factory import get_evaluator
 
3
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  def fix_ans(answer):
6
 
@@ -89,6 +100,10 @@ def question_scorer(prediction, gold_answer):
89
  if not run_eval:
90
  return 0.
91
 
 
 
 
 
92
  metric_eval = get_evaluator(evaluator)
93
  accuracy = metric_eval(prediction, gold_answer)
94
- return accuracy
 
1
  import json
2
  from evaluation.evaluate_utils.evaluate_factory import get_evaluator
3
+ import numpy as np
4
 
5
+ def find_isnan(samp):
6
+
7
+ try:
8
+ if np.isnan(samp):
9
+ return True
10
+ else:
11
+ return False
12
+ except:
13
+ return False
14
+
15
 
16
  def fix_ans(answer):
17
 
 
100
  if not run_eval:
101
  return 0.
102
 
103
+ has_ans = 1.
104
+ if ((type(x['prediction']) != float and len(x["prediction"]) == 0) or find_isnan(x['prediction'])):
105
+ has_ans = 0.
106
+
107
  metric_eval = get_evaluator(evaluator)
108
  accuracy = metric_eval(prediction, gold_answer)
109
+ return accuracy, has_ans