我正在使用python 3,并使用Dipanjan Sarkar Text分析书在NLP中执行一些任务。
使用的命令:-
avg_wv_train_features = averaged_word_vectorizer(corpus=tokenized_train,
model=model,
num_features=500)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-34-4e2b1d1af3ae> in <module>()
1 avg_wv_train_features = averaged_word_vectorizer(corpus=tokenized_train,
2 model=model,
----> 3 num_features=500)
/Users/tcssig/anaconda/lib/python3.5/site-packages/Ch04_Text_Classification/feature_extractors.py in averaged_word_vectorizer(corpus, model, num_features)
58
59 def averaged_word_vectorizer(corpus, model, num_features):
---> 60 vocabulary = set(model.wv.index2word)
61 features = [average_word_vectors(tokenized_sentence, model, vocabulary, num_features)
62 for tokenized_sentence in corpus]
AttributeError: 'Word2Vec' object has no attribute 'index2word'
根据论坛上提出的其他问题,我正在使用gensim 3.7.0,并且正在使用model.wv.index2word而不是model.index2word。但是仍然出现上述错误。我已经提到过'Word2Vec' object has no attribute 'index2word'