get_top_tokens

Get the specified number of top most frequent tokens.

Alert

This method is implemented only for the FrequencyBased dictionary type.

Method call format

get_top_tokens(top_size=None)

Parameters

top_size

Description

The top size to output.

Data types

int

Default value

10

Type of return value

list

Example

from catboost.text_processing import Dictionary

dictionary = Dictionary(occurence_lower_bound=0)\
    .fit(['A', 'C', 'C', 'A', 'B', 'A', 'D'])

print(dictionary.get_top_tokens(2))

Output:

['A', 'C']