Giter Club home page Giter Club logo

Comments (29)

cjhutto avatar cjhutto commented on June 19, 2024 3

(Note: this upgrade uses Python 3x)

after you've run
$ pip install --upgrade vaderSentiment

try this in your python terminal or IDE:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
vs = analyzer.polarity_scores("this is a good example")
print(str(vs))
print(str(vs["compound"]))

from vadersentiment.

hardiksakhuja avatar hardiksakhuja commented on June 19, 2024 3

@cjhutto Okay , I fixed the problem . I still dont know what was it exactly. But i thought the cached image must have something wrong with it or I came upon this discussion where the package may not get fetched for python version you are using
python -m pip install vaderSentiment --no-cache-dir
instead of just "pip install vaderSentiment"
This did the trick. It all works fine now !!!

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024 2

You can always use
pip uninstall vaderSentiment
Then use the typical commands to install a particular version, for example:
pip install vaderSentiment==versionyouwant
or even:
pip install vaderSentiment<2.0

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024 2

Hi @harika5,
It looks like you're trying to use the new version of VADER with an older version of the import code snippet...

As seen in the updated code examples on the first page of the VADER GitHub, your import should look like this:

    from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
    #note: depending on how you installed (e.g., using source code download versus pip install), you may need to import like this:
    #from vaderSentiment import SentimentIntensityAnalyzer

then you should be able to run your text though the analyzer like this:

analyzer = SentimentIntensityAnalyzer()
vs = analyzer.polarity_scores("this is a good example")
print(str(vs))
print(str(vs["compound"]))

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024 2

Oh good!
python -m pip install vaderSentiment --no-cache-dir
is a great thing to keep in mind ... maybe this will help others as well.
Thanks for adding the note!

from vadersentiment.

mp31415 avatar mp31415 commented on June 19, 2024

In the example there is an alternative way to import:

from vaderSentiment.vaderSentiment import sentiment as vaderSentiment

Would it help?

from vadersentiment.

jatkins23 avatar jatkins23 commented on June 19, 2024

Yes, that helped, thank you. Apologies for the unnecessary issue. Though I
was still unable to link it via pip install, cloning the repository is fine
for my scale of app.

Any advice on how to change/add to the dictionary? Basically, I am
analyzing political tweets from the past week and am trying to add links
(to popular memes from that time that have a sentiment) and in particular
just to add the word "nazi," by copying and pasting the syntax and values
from the word ni***r. I have tried everything, including just replacing the
string "nazi" with the its sentiment equivalent word before calling
vaderSentiment(), but that doesn't work either. I'm sure its an issue on my
part, but would love any help if you don't mind. Thank you!

Jon

On Mon, May 9, 2016 at 4:00 PM, mp31415 [email protected] wrote:

In the example there is an alternative way to import:

from vaderSentiment.vaderSentiment import sentiment as vaderSentiment

Would it help?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#8 (comment)

Jon Atkins
BS Computer Science
Tufts University 2016

from vadersentiment.

mp31415 avatar mp31415 commented on June 19, 2024

I didn't try to modify the dictionary, but I don't see why "nazi" would be any different from any other entry in the dictionary. I did notice though that on non-Windows platform encoding of the dictionary must be changed to UTF-8 and some invalid entries must be fixed (see one of the recent issues).

I also noticed that dictionary file may be put next to your python file (in the same folder), because vader first tries to open it there and only if it fails falls back to the original file in the vader package.

from vadersentiment.

cvint13 avatar cvint13 commented on June 19, 2024

When I tried both possible ways to import listed above, I got the following error:

File "/usr/anaconda3/lib/python3.5/site-packages/vaderSentiment/vaderSentiment.py", line 23
return dict(map(lambda (w, m): (w, float(m)), [wmsr.strip().split('\t')[0:2] for wmsr in open(f) ]))
^
SyntaxError: invalid syntax

Is this a python 3 issue or something?

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024

Thanks! The new update (with new pip install) has better compatibility support for Python 3 to address cvint13's issue, and helps with the encoding/decoding issues. The lexicon dictionary file has been encoded with UTF-8 unicode by default (I hope) for better cross-os performance. I've implemented code to automatically detect where the dictionary file is installed (as long as you didn't change it's location relative to where the actual "vaderSentiment.py" file got installed), so no longer any need to manually put a copy of the dictionary file next to your python file (in the same folder)... from what I can tell, my implementation should work across OSs.

from vadersentiment.

simonanez avatar simonanez commented on June 19, 2024

@cjhutto Before i imported using: "from vaderSentiment.vaderSentiment import sentiment as vaderSentiment" on python 2.7
Now with the new pip install i get: ImportError: cannot import name sentiment
What's the new way to import and the new method to run sentiment analysis?

from vadersentiment.

simonanez avatar simonanez commented on June 19, 2024

@cjhutto What are the instructions to install the previous version?
I've been doing a project that's due in a few days, i tried on a different computer with the new version to run sentiment analysis on 400k tweets and it's been taking over 30 minutes (still going) whether as before it just took 2-3 minutes max

from vadersentiment.

harika5 avatar harika5 commented on June 19, 2024

I am still getting the same error even after trying both the import options.
I am using python 3.5 and vaderSentiment version is 2.5

from vaderSentiment import sentiment as vaderSentiment
ImportError: cannot import name 'sentiment'

Does anyone have any solution to this??

from vadersentiment.

jyayoub avatar jyayoub commented on June 19, 2024

hi, I was able to download vaderSentiment, but each time I try to import it from python using this from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer, I recieve this error:

import vaderSentiment
Traceback (most recent call last):
File "<pyshell#21>", line 1, in
import vaderSentiment
ModuleNotFoundError: No module named 'vaderSentiment'

from vadersentiment.

Raunak24x7 avatar Raunak24x7 commented on June 19, 2024

ModuleNotFoundError Traceback (most recent call last)
in
5 import pandas as pd
6 import numpy as np
----> 7 from vaderSentiment.vaderSentiment import sentiment as vaderSentiment
8 from wordcloud import WordCloud
9 import nltk

ModuleNotFoundError: No module named 'vaderSentiment'

from vadersentiment.

hardiksakhuja avatar hardiksakhuja commented on June 19, 2024

@Raunak24x7 i am getting the same error . Have you been able to fix it yet ?

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024

Have you looked at the code examples provided on the VADER GitHub homepage? I think your solution is already provided there...

for example, see the new import method:

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

from vadersentiment.

hardiksakhuja avatar hardiksakhuja commented on June 19, 2024

`from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

analyzer = SentimentIntensityAnalyzer()`

File ".\vaderSentiment.py", line 4, in
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
File "E:\Final Project\vaderSentiment.py", line 4, in
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
ModuleNotFoundError: No module named 'vaderSentiment.vaderSentiment'; 'vaderSentiment' is not a package

I have used vaderSentiment recently like a month back and it worked like a charm . i went back to my code to do some more digging and now it shows me this . 1 month back this exact thing was working just fine .

PS - i have uninstalled the package too . Reinstalled it again . and that didnt help me too

from vadersentiment.

cjhutto avatar cjhutto commented on June 19, 2024

Not sure what to tell you -- I'm not able to reproduce your error. I just tested it with a fresh install on a new virtual environment, and then ran the example code shown on the homepage. It all worked with no errors at all.

vader

from vadersentiment.

yelizkilinc avatar yelizkilinc commented on June 19, 2024

I have read all of them but any of them did not work for me. I am using tabPy on Tableau.
I am getting: 'ModuleNotFoundError : No module named 'vaderSentiment'' error.
I can see that module exists on C:\Python39\Lib\site-packages\vaderSentiment.
My python version is 3.9.1
I hope you have an idea?

from vadersentiment.

Raunak24x7 avatar Raunak24x7 commented on June 19, 2024

from vadersentiment.

yelizkilinc avatar yelizkilinc commented on June 19, 2024

I solved the above issue. TabPy was looking to another path, not Python folder. I copied files to correct path. But this time, init.py file is empty. And I am getting ImportError : cannot import name 'SentimentIntensityAnalyzer' from 'vaderSentiment' (c:\anaconda3\lib\site-packages\vaderSentiment_init_.py) error. I wrote by myself, but it did not accept.

from vadersentiment.

yelizkilinc avatar yelizkilinc commented on June 19, 2024

Please do not try to solve. I solved it, it can be done without init.py. I came at the beginning and your suggestions above worked. Thanks

from vadersentiment.

Raunak24x7 avatar Raunak24x7 commented on June 19, 2024

from vadersentiment.

kirch-47 avatar kirch-47 commented on June 19, 2024

Please do not try to solve. I solved it, it can be done without init.py. I came at the beginning and your suggestions above worked. Thanks

So how did you fix it? As I am getting this error as well: ImportError: cannot import name 'SentimentIntensityAnalyzer' from 'vaderSentiment' (c:\Users\Aiden\OneDrive\Documents\WsB workspace VS.venv\lib\site-packages\vaderSentiment_init_.py)

from vadersentiment.

kirch-47 avatar kirch-47 commented on June 19, 2024

Please do not try to solve. I solved it, it can be done without init.py. I came at the beginning and your suggestions above worked. Thanks

So how did you fix it? As I am getting this error as well: ImportError: cannot import name 'SentimentIntensityAnalyzer' from 'vaderSentiment' (c:\Users\Aiden\OneDrive\Documents\WsB workspace VS.venv\lib\site-packages\vaderSentiment__init__.py)

@yelizkilinc

from vadersentiment.

Raunak24x7 avatar Raunak24x7 commented on June 19, 2024

from vadersentiment.

tuvshuug avatar tuvshuug commented on June 19, 2024

I had the same problems. The resolution is I deleted the git cloned vadersentiment folder. then I did

  1. pip uninstall vaderSentiment
  2. python -m pip install vaderSentiment --no-cache-dir
  3. or pip install --upgrade vaderSentiment

Good luck guys

from vadersentiment.

Shyam2214 avatar Shyam2214 commented on June 19, 2024

Trying to install sentiments for my web app that work on python flaks i pip install sentiments but when I run code it shows module name sentiments not found

from vadersentiment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.