python - NLTK sentiment vader: polarity_scores(text) not working -
i trying use polarity_scores() vader sentiment analysis in nltk, gives me error:
polarity_scores() missing 1 required positional argument: 'text'
i totally beginner in python. appreciate help!
from nltk.sentiment.vader import sentimentintensityanalyzer sid sentences=["hello","why not working?!"] sentence in sentences: ss = sid.polarity_scores(sentence)
sentimentintensityanalyzer class. need initialize object of sentimentintensityanalyzer , call polarity_scores() method on that.
from nltk.sentiment.vader import sentimentintensityanalyzer sia sentences=["hello","why not working?!"] sid = sia() sentence in sentences: ss = sid.polarity_scores(sentence) you may have download lexicon file if haven't already
>>> import nltk >>> nltk.download() --------------------------------------------------------------------------- d) download l) list u) update c) config h) q) quit --------------------------------------------------------------------------- downloader> d vader_lexicon downloader> q
Comments
Post a Comment