Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-340

Vocabulary Minimum Frequency Filter

Problem

Vocabulary pruning keeps only tokens whose count reaches a minimum frequency.

Given tokens and the minimum frequency, return the sorted list of kept token types.

Hint

Count first, then filter and sort the survivors.

Test cases

case 1
in: [["a","b","a","b","a"],2]
expected: ["a","b"]
case 2
in: [["x","y"],2]
expected: []
case 3
in: [["q"],0]
expected: ["q"]
Starter codePython
def vocabulary_minimum_frequency_filter(tokens, min_freq):
    # Your code here
    pass

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