Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-239

Vocabulary Coverage Percentage

Problem

Return the percentage of token occurrences covered by vocab, counting occurrences rather than distinct types.

Return 0.0 when tokens is empty.

Hint

This is the occurrence-level complement of an OOV rate, expressed as a percentage.

Test cases

case 1
in: [["a","b","z"],["a","b"]]
expected: 66.66666666666667
case 2
in: [[],["a"]]
expected: 0
case 3
in: [["a","a"],["a"]]
expected: 100
case 4
in: [["x"],[]]
expected: 0
Starter codePython
def vocab_coverage_percentage(tokens, vocab):
    # Your code here
    pass

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