Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error message with nltk.sentiment.vader in Python

Tags:

python

nltk

I am a beginner at Python and am trying to use nltk.sentiment.vader but get a recurrent error message despite multiple attempts to fix it. I previously installed most of NTLK (3 modules were out of date so couldn't install them). I then installed nltk.sentiment.vader using the command line prompt and my output was "Successfully installed vaderSentiment-2.5". "vaderSentiment in c:\anaconda\lib\site-packages". I then run the script below and repeatedly get the error message below:

from nltk.sentiment.vader import SentimentIntensityAnalyzer
sid = SentimentIntensityAnalyzer()
ss = sid.polarity_scores(sentence_that_I want_to_analyze)  
print(ss)

output:

LookupError:


Resource 'sentiment/vader_lexicon.zip/vader_lexicon/vader_lexicon.txt' not found. Please use the NLTK Downloader to obtain the resource: >>> nltk.download() Searched in: - 'C:\Users\name/nltk_data' - 'C:\nltk_data' - 'D:\nltk_data' - 'E:\nltk_data' - 'C:\Anaconda\nltk_data' - 'C:\Anaconda\lib\nltk_data' - 'C:\Users\name\AppData\Roaming\nltk_data' - ''


I noticed that the error message doesn't include the location where the package was installed =c:\anaconda\lib\site-packages. Is this the reason that I am getting this error? How do I fix this?

Thank you very much for the help

like image 249
learningcompsci Avatar asked Apr 21 '17 15:04

learningcompsci


1 Answers

import nltk
nltk.downloader.download('vader_lexicon')

instead of 'vader_lexicon',put your desired package

like image 107
A_emperio Avatar answered Oct 22 '22 10:10

A_emperio