python-3.xsublimetext3sentiment-analysisgensim

'gensim.models.doc2vec' has no attribute 'LabeledSentence'


I am using gensim in python 3 as shown within image below

 Image

In line no 11 I am getting the following error:

Image


Solution

  • It's a deprecated import:

    https://github.com/RaRe-Technologies/gensim/issues/1886

    if you want to use LabeledSentenced you must import it from the deprecated section:

    from gensim.models.deprecated.doc2vec import LabeledSentence
    

    So you have to do this:

    LabeledSentence = gensim.models.deprecated.doc2vec.LabeledSentence