Skip to content

Commit 12c6275

Browse files
committed
Switch wer_cer_batch to compute real CER over corpus
1 parent f3613da commit 12c6275

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

util/text.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,20 @@ def wer_cer_batch(originals, results):
7676
assert len(originals) == len(results)
7777

7878
total_cer = 0.0
79+
total_char_length = 0.0
7980

8081
total_wer = 0.0
8182
total_word_length = 0.0
8283

8384
for original, result in zip(originals, results):
8485
total_cer += levenshtein(original, result)
86+
total_char_length += len(original)
8587

8688
total_wer += levenshtein(original.split(), result.split())
8789
total_word_length += len(original.split())
8890

89-
return total_wer / total_word_length, total_cer / len(originals)
91+
return total_wer / total_word_length, total_cer / total_char_length
92+
9093

9194
# The following code is from: http://hetland.org/coding/python/levenshtein.py
9295

0 commit comments

Comments
 (0)