close editdistance package format warning

pull/879/head
Hui Zhang 3 years ago
parent 466672e1de
commit 8977f1850e

@ -19,6 +19,8 @@ import numpy as np
__all__ = ['word_errors', 'char_errors', 'wer', 'cer']
editdistance.eval("a", "b")
def _levenshtein_distance(ref, hyp):
"""Levenshtein distance is a string metric for measuring the difference
@ -90,6 +92,7 @@ def word_errors(reference, hypothesis, ignore_case=False, delimiter=' '):
hyp_words = list(filter(None, hypothesis.split(delimiter)))
edit_distance = _levenshtein_distance(ref_words, hyp_words)
# `editdistance.eavl precision` less than `_levenshtein_distance`
# edit_distance = editdistance.eval(ref_words, hyp_words)
return float(edit_distance), len(ref_words)
@ -121,6 +124,7 @@ def char_errors(reference, hypothesis, ignore_case=False, remove_space=False):
hypothesis = join_char.join(list(filter(None, hypothesis.split(' '))))
edit_distance = _levenshtein_distance(reference, hypothesis)
# `editdistance.eavl precision` less than `_levenshtein_distance`
# edit_distance = editdistance.eval(reference, hypothesis)
return float(edit_distance), len(reference)

@ -1,4 +1,5 @@
coverage
editdistance
gpustat
jsonlines
kaldiio
@ -19,4 +20,3 @@ tqdm
typeguard
visualdl==2.2.0
yacs
editdistance
Loading…
Cancel
Save