Incompatibility of WordClasses.py with Gensim 4.0+: Missing .wv attribute for FastText model operations
The Word_Classes.py module is incompatible with Gensim 4.0 and later versions due to changes in how FastText models expose word vector operations. In Gensim 4.0, word vector operations were moved from the model object directly to a .wv (KeyedVectors) attribute.
The following 5 lines are affected:
Line 87: vector = model[word] → Fix: vector = model.wv[word]
Line 153: ranks = model.rank_by_centrality(words=category_df.loc[:,"Word"], use_norm=True) → Fix: ranks = model.wv.rank_by_centrality(words=category_df.loc[:,"Word"], use_norm=True)
Line 158: mean_vector = model.get_mean_vector(keys=ranks.loc[:,"Word"], weights=ranks.loc[:,"Rank"], pre_normalize=True, post_normalize=True) → Fix: mean_vector = model.wv.get_mean_vector(keys=ranks.loc[:,"Word"], weights=ranks.loc[:,"Rank"], pre_normalize=True, post_normalize=True)
Line 162: exemplars = model.similar_by_vector(mean_vector, topn=10000) → Fix: exemplars = model.wv.similar_by_vector(mean_vector, topn=10000)
Line 181: vector = model[phrase] → Fix: vector = model.wv[phrase]