Spaces:
Runtime error
Runtime error
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 filesThere 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.
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 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
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
|
|