gensim.corpora.Dictionary.filter_n_most_frequent

Dictionary.filter_n_most_frequent(remove_n)[source]

Filter out the ‘remove_n’ most frequent tokens that appear in the documents.

After the pruning, shrink resulting gaps in word ids.

Note: Due to the gap shrinking, the same word may have a different word id before and after the call to this function!