Yeshwant123 commited on
Commit
f6cba11
1 Parent(s): 9bf831d

There is an else statement that is present in the code which is not required so it is removed

Browse files

There is an else statement that is present in the code which is not required as there is a return statement so it can be removed and the else block can be shifted to front.

Files changed (1) hide show
  1. wer.py +7 -8
wer.py CHANGED
@@ -96,11 +96,10 @@ class WER(evaluate.Metric):
96
  def _compute(self, predictions=None, references=None, concatenate_texts=False):
97
  if concatenate_texts:
98
  return compute_measures(references, predictions)["wer"]
99
- else:
100
- incorrect = 0
101
- total = 0
102
- for prediction, reference in zip(predictions, references):
103
- measures = compute_measures(reference, prediction)
104
- incorrect += measures["substitutions"] + measures["deletions"] + measures["insertions"]
105
- total += measures["substitutions"] + measures["deletions"] + measures["hits"]
106
- return incorrect / total
 
96
  def _compute(self, predictions=None, references=None, concatenate_texts=False):
97
  if concatenate_texts:
98
  return compute_measures(references, predictions)["wer"]
99
+ incorrect = 0
100
+ total = 0
101
+ for prediction, reference in zip(predictions, references):
102
+ measures = compute_measures(reference, prediction)
103
+ incorrect += measures["substitutions"] + measures["deletions"] + measures["insertions"]
104
+ total += measures["substitutions"] + measures["deletions"] + measures["hits"]
105
+ return incorrect / total