metalcorebear / nrclex Goto Github PK
View Code? Open in Web Editor NEWAn affect generator based on TextBlob and the NRC affect lexicon. Note that lexicon license is for research purposes only.
License: MIT License
An affect generator based on TextBlob and the NRC affect lexicon. Note that lexicon license is for research purposes only.
License: MIT License
Hey, thanks for the library! Though would like to understand the output better. For some sentences, the emotion score is constant, though the sentence doesn't have that variety of emotion.
FileNotFoundError Traceback (most recent call last)
in
----> 1 from nrclex import NRCLex
C:\ProgramData\Anaconda3\envs\keyword2\lib\site-packages\nrclex.py in
28 self.affect_frequencies = dict(affect_frequencies)
29
---> 30 class NRCLex:
31
32 """Lexicon source is (C) 2016 National Research Council Canada (NRC) and library is for research purposes only. Source: http://sentiment.nrc.ca/lexicons-for-research/"""
C:\ProgramData\Anaconda3\envs\keyword2\lib\site-packages\nrclex.py in NRCLex()
33
34 #lexicon = {'fawn': ['negative'], 'pardon': ['positive'], 'cussed': ['anger']}
---> 35 with open('lexicon.pkl', 'r') as pkl_file:
36 lexicon = pickle.load(pkl_file)
37
There were also "UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position" happened multiple times during the installation. I'm not sure where I did wrong. Maybe this is the reason why the error occurred.
Eventually, I downloaded NRCLex locally, and it works well.
Hope that everything is fine, cheers.
Hi,
What a great package, thank you.
What do you think about the following outcome:
input code:
text = 'In three years, everyone will be happy.'
emotion = NRCLex(text)
result = emotion.affect_frequencies
result
output:
{'fear': 0.0,
'anger': 0.0,
'anticip': 0.0,
'trust': 0.25,
'surprise': 0.0,
'positive': 0.25,
'negative': 0.0,
'sadness': 0.0,
'disgust': 0.0,
'joy': 0.25,
'anticipation': 0.25}
There is 2 items that are anticip and anticipation, clearly one of them is extra but in the following example we have just one of them:
input code:
text = 'Marie is a published author.'
emotion = NRCLex(text)
result = emotion.affect_frequencies
result
output:
{'fear': 0.0,
'anger': 0.0,
'anticip': 0.0,
'trust': 0.5,
'surprise': 0.0,
'positive': 0.5,
'negative': 0.0,
'sadness': 0.0,
'disgust': 0.0,
'joy': 0.0}
Thank you for your time.
Hi! I appreciate your work, but I been struggling on finding the Indonesian lexicon like the one provided in the original website.
I want to use this library for my research. Thank you
Dear Mark,
My name is Saif Mohammad, one of the creators of the NRC Emotion Lexicon: http://saifmohammad.com
It was great to see the tool you have built using the NRC Emotion Lexicon. Can you please add to the About page how people can cite the lexicon:
"Crowdsourcing a Word-Emotion Association Lexicon, Saif Mohammad and Peter Turney, Computational Intelligence, 29 (3), 436-465, 2013."
Citing it gives us credit for the work and the terms of use of the lexicon require that the paper be cited if the lexicon is used: http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm
(scroll to the bottom)
Also, I noticed that the url you have for the lexicon points to a now defunct page. Please use this url if you intend to point to the NRC Emotion lexicon: http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm
Or this url if you intend to point to the many emotion lexicons developed at NRC: http://saifmohammad.com/WebPages/lexicons.html
If you would like to chat with me or I can clarify anything, please do not hesitate to reach out. You can reach me at [email protected]. I am always keen to learn how people use the lexicon.
Thank you and best wishes.
-Saif
testing string: "give me money when in need"
when returning an NRCLex text object with .affect_frequencies::
{'fear': 0.0,
'anger': 0.16666666666666666,
'anticip': 0.0,
'trust': 0.16666666666666666,
'surprise': 0.16666666666666666,
'positive': 0.16666666666666666,
'negative': 0.0,
'sadness': 0.0,
'disgust': 0.0,
'joy': 0.16666666666666666,
'anticipation': 0.16666666666666666}
^ both 'anticip' and 'anticipation' were returned. I saw a recent change in the repo here would likely fix the problem. May I know when the next release date will be?
Hi,
When using NRCLex, sometimes the affect frequencies shows the anticipation emotion (not anticip), but not every time.
Here is an example:
In: NRCLex("another day, another opportunity").affect_frequencies
Out: {'fear': 0.0, 'anger': 0.0, 'anticip': 0.0, 'trust': 0.0, 'surprise': 0.0, 'positive': 0.5, 'negative': 0.0, 'sadness': 0.0, 'disgust': 0.0, 'joy': 0.0, 'anticipation': 0.5}
In: NRCLex("another day").affect_frequencies
Out: {'fear': 0.0, 'anger': 0.0, 'anticip': 0.0, 'trust': 0.0, 'surprise': 0.0, 'positive': 0.0, 'negative': 0.0, 'sadness': 0.0, 'disgust': 0.0, 'joy': 0.0}
Any explanation for why this might be? Is there a way to get the same returns every time?
Hi,
Thank you for the project. I saw different outputs when alternating the capitalization of input, for example:
text = "I love to visit historical places"
emotion = NRCLex(text)
print(emotion.top_emotions)
yields [('positive', 0.6666666666666666)], with raw emotion score {'joy': 1, 'positive': 2}.
while if I change text to "I Love to visit historical places", the top_emotions becomes [('positive', 1.0)].
How do we explain this? I understand this might not be an issue, but I am curious as a beginner in NLP.
Thank you for building this repository! In the description, you stated that "Affect dictionary contains approximately 27,000 words." But there are less than 10,000 words in nrc_en.json. Could you update the file to include more words?
Hi please how do I install it in my terminal? I've checked online and didn't get any help.
Thanks.
text_object = NRCLex('not happy')
text_object.raw_emotion_scores
{'anticipation': 1, 'joy': 1, 'positive': 1, 'trust': 1}
What to do in this case?
Thanks
affect_frequencies has 'anticip' key with value that is always zero because only 'anticipation' is used in lexicon. Suggesting changing 'anticip' to 'anticipation' in the affect_percent variable in the build_word_affect() function in nrclex.py.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.