Skip to main content

find emotion scores from a list of words

Project description

emotion

This module is a emotion classifier that classifies emotion of a list of words and gives aggregated scores for each emotion. The classifier is based on NRC Affect Intensity Lexicon. The lexicon has close to 10,000 entries for eight emotions that Robert Plutchik argued to be basic or universal:

  1. Joy
  2. Sadness
  3. Anger
  4. Fear
  5. Disgust
  6. Anticipation
  7. Trust
  8. Surprise

Lexicon source is (C) 2020 National Research Council Canada (NRC) and this package is for research purposes only. Source: [lexicons for research] (http://www.saifmohammad.com/WebPages/AffectIntensity.htm) Some words has multiple emotions to varying degree. Here is how the classifier works:

  • The classifier first matches the words with the lexicon and fetches the emotions and intensity score for each matching from the lexicon.

  • Then it sums the scores along the emotions and gives a mood score of the song. The emotion intensity are given from 0 to 1 in floats so the aggregated score is a float as well.

  • It multiplies the number of appearances of these mood words in the song with the intensity score to give a corrected weighting of each emotion.

For now the input has to be a list of words rather than a text body. I will change it in the next update. Please convert the text body into a list of words for using this package.

Installation

Run the following to install:

pip install emotion_nrc_affect_lex

Usage

from emotion import*
text = ['I','hate','everything','about','you','Why','do','I','love','you'] # The input should be a list of words. Please convert your text body to a list before using this package.
emo_object = Emo(text)
# Gives aggregated emotion scores for the whole list.
emo_object.weighted_emotion_scores
# Dictionary of each of the affect words
emo_object.affect_dict
# Gives number of words for each emotion
emo_object.raw_emotion_scores
# Gives a list of affect words and their frequencies
emo_object.word_frequencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

emotion_nrc_affect_lex-0.0.3-py3-none-any.whl (70.0 kB view details)

Uploaded Python 3

File details

Details for the file emotion_nrc_affect_lex-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: emotion_nrc_affect_lex-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 70.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for emotion_nrc_affect_lex-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 501f6a9a09e769ef9b3c5d9444f2b943646039b2cb53c3cb3770258a47e47485
MD5 b99de5b2e62a454c843144bfeed5302c
BLAKE2b-256 611625c1df1f8307a8209ede93fec3174123ecb21f808c1115457a6398c228e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page