All problems
ASR Confidence Average
Problem
Return the token-length-weighted average confidence: sum(len(token) * confidence) / sum(len(token)).
Return 0.0 when there are no tokens or all token lengths are 0.
Hint
Longer tokens weigh more because they contribute more characters.
Test cases
case 1
in: [["ab","c"],[0.5,1]]
expected: 0.6666666666666666
case 2
in: [["a"],[0.9]]
expected: 0.9
case 3
in: [[],[]]
expected: 0
case 4
in: [["","xy"],[0.1,0.5]]
expected: 0.5
case 5
in: [["ab","c"],[0,0]]
expected: 0
Starter codePython
def asr_confidence_average(tokens, confidences):
# Your code here
pass5 test cases · run your code against them in the editor