Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-302

Normalized Character Error Rate

Problem

Compute character error rate after normalization. Lowercase both strings and keep only alphanumeric characters, then take the Levenshtein distance between the cleaned strings divided by the cleaned reference length.

Return 0.0 when both cleaned strings are empty and 1.0 when only the reference is empty.

Hint

Normalize first, then run the character-level edit-distance table.

Test cases

case 1
in: ["Hello, World!","hello world"]
expected: 0
case 2
in: ["abc","ab"]
expected: 0.3333333333333333
case 3
in: ["A-B","A B"]
expected: 0
case 4
in: ["",""]
expected: 0
case 5
in: ["","x"]
expected: 1
Starter codePython
def normalized_cer(reference, hypothesis):
    # Your code here
    pass

5 test cases · run your code against them in the editor