Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-405

Query Term Coverage

Problem

Coverage is the fraction of distinct query terms that appear in a document: |Q intersect D| / |Q|, with 1.0 for an empty query.

Given the query and document tokens, return the coverage.

Hint

Use distinct query terms in the denominator.

Test cases

case 1
in: [["a","b"],["a","c"]]
expected: 0.5
case 2
in: [["x"],["x"]]
expected: 1
case 3
in: [[],["anything"]]
expected: 1
Starter codePython
def query_term_coverage(query, document_tokens):
    # Your code here
    pass

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