ArabicOCR / py3 /utils /error_rates.py
msaeed3
version 1.0
e295beb
raw
history blame contribute delete
394 Bytes
import editdistance
def cer(r, h):
#Remove any double or trailing
r = ' '.join(r.split())
h = ' '.join(h.split())
return err(r, h)
def err(r, h):
dis = editdistance.eval(r, h)
if len(r) == 0.0:
return len(h)
# print(float(dis) / float(len(r)))
return float(dis) / float(len(r))
def wer(r, h):
r = r.split()
h = h.split()
return err(r,h)