libraxiong commited on
Commit
5293913
·
verified ·
1 Parent(s): 62d04e5

Update oppo_refuse_match.py

Browse files
Files changed (1) hide show
  1. oppo_refuse_match.py +6 -5
oppo_refuse_match.py CHANGED
@@ -27,7 +27,7 @@ Returns the rate at which the input predicted strings exactly match the refuse l
27
 
28
  _KWARGS_DESCRIPTION = """
29
  Args:
30
- predictions: List of predicted texts.
31
 
32
  Returns:
33
  exact_match: Dictionary containing oppo_refuse_match rate. Possible values are 0 or 1
@@ -61,7 +61,8 @@ class OppoRefuseMatch(evaluate.Metric):
61
  patterns = [
62
  r"There is no", r"no", r"non-existent", r"not a", r"none"
63
  ]
64
- if has_answer(predictions,patterns):
65
- return {"oppo_refuse_match": 1}
66
- else:
67
- return {"oppo_refuse_match": 0}
 
 
27
 
28
  _KWARGS_DESCRIPTION = """
29
  Args:
30
+ predictions: List of predicted texts. -> [prediction] only one
31
 
32
  Returns:
33
  exact_match: Dictionary containing oppo_refuse_match rate. Possible values are 0 or 1
 
61
  patterns = [
62
  r"There is no", r"no", r"non-existent", r"not a", r"none"
63
  ]
64
+ score_list=0
65
+ for prediction in predictions:
66
+ if has_answer(prediction,patterns):
67
+ score_list+=1
68
+ return {"oppo_refuse_match": score_list/len(predictions)}