Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-131

Good-Turing Adjusted Count

Problem

Return the Good-Turing adjusted count r* = (r + 1) * N_{r+1} / N_r, where count_of_counts maps each raw count to how many events had that count.

Return 0.0 when N_r is 0. Numeric or string keys are accepted.

Hint

Look up the frequencies of r and r + 1 in the count-of-counts table.

Test cases

case 1
in: [1,{"1":5,"2":2}]
expected: 0.8
case 2
in: [2,{"2":3,"3":1}]
expected: 1
case 3
in: [5,{"1":2}]
expected: 0
case 4
in: [1,{}]
expected: 0
Starter codePython
def good_turing_adjusted_count(r, count_of_counts):
    # Your code here
    pass

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