gensim.corpora.Dictionary.compactify

Dictionary.compactify()[source]

Assign new word ids to all words.

This is done to make the ids more compact, e.g. after some tokens have been removed via filter_tokens() and there are gaps in the id series. Calling this method will remove the gaps.