Commit 50cd6450 authored by szr712's avatar szr712

增加计算总CER的代码

parent 8735fd67
......@@ -34,6 +34,9 @@ def cer(preFile,textFile):
# for a,b in zip(textList,preList):
# print('pred: {}, gt: {}'.format(b, a))
all_edit_distance=0
all_chars=0
for pre in os.listdir(preFile):
# text=pre[:-11]+".txt"
text=pre
......@@ -55,9 +58,14 @@ def cer(preFile,textFile):
print("Total CER: {}/{}={}\n".format(total_edit_distance,
num_chars,
round(float(total_edit_distance)/num_chars, 5)))
all_edit_distance+=total_edit_distance
all_chars+=num_chars
print("Average CER: {}/{}={}\n".format(all_edit_distance,
all_chars,
round(float(all_edit_distance)/all_chars, 5)))
if __name__ == "__main__":
preFile = "./data/test_data/tmp/2"
textFile = "./data/test_data/tmp/3"
preFile = "./data/test/pre"
textFile = "./data/test/hanzi"
cer(preFile,textFile)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment