All problems
Translation Edit Rate
Problem
Return the translation edit rate from an edit count triple: sum of [substitutions, insertions, deletions] divided by the reference length.
Return 0.0 when the reference length is not positive.
Hint
The three edit types are summed before normalizing by the reference length.
Test cases
case 1
in: [[1,0,0],4]
expected: 0.25
case 2
in: [[0,0,0],5]
expected: 0
case 3
in: [[2,1,1],8]
expected: 0.5
case 4
in: [[1,1,1],0]
expected: 0
Starter codePython
def ter(edit_counts, reference_length):
# Your code here
pass4 test cases · run your code against them in the editor