diff --git a/gensim/models/word2vec.py b/gensim/models/word2vec.py index b8bb24f185..8c371ea8bd 100644 --- a/gensim/models/word2vec.py +++ b/gensim/models/word2vec.py @@ -727,7 +727,7 @@ def finalize_vocab(self, update=False): def sort_vocab(self): """Sort the vocabulary so the most frequent words have the lowest indexes.""" if len(self.wv.syn0): - raise RuntimeError("must sort before initializing vectors/weights") + raise RuntimeError("cannot sort vocabulary after model weights already initialized.") self.wv.index2word.sort(key=lambda word: self.wv.vocab[word].count, reverse=True) for i, word in enumerate(self.wv.index2word): self.wv.vocab[word].index = i