Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-416

Collection Term Frequency

Problem

Collection term frequency is the total number of occurrences of a term across all documents.

Given the documents (each a token list) and the term, return the total count.

Hint

Sum per-document counts.

Test cases

case 1
in: [[["a","a"],["a"]],"a"]
expected: 3
case 2
in: [[["x"],["y"]],"z"]
expected: 0
case 3
in: [[["b","b","b"]],"b"]
expected: 3
Starter codePython
def collection_term_frequency(documents, term):
    # Your code here
    pass

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