Created
January 1, 2019 16:25
-
-
Save Deepayan137/853df7b6543c3ac7c05423f2cacf4f6e to your computer and use it in GitHub Desktop.
Character accuracy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Levenshtein as lev | |
def cer(prediction, target): | |
sum_edit_dists = lev.distance(prediction, target) | |
sum_gt_lengths = sum(map(len, target)) | |
fraction = sum_edit_dists/sum_gt_lengths | |
percent = fraction*100 | |
return (100.0-percent) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment