Skip to main content

An affect generator based on TextBlob and the NRC affect lexicon. Note that lexicon license is for research purposes only.

Project description


(C) 2019 Mark M. Bailey


NRCLex will measure emotional affect from a body of text. Affect dictionary contains approximately 27,000 words, and is based on the National Research Council Canada (NRC) affect lexicon (see link below) and the NLTK library's WordNet synonym sets.

Lexicon source is (C) 2016 National Research Council Canada (NRC) and this package is for research purposes only. Source: [lexicons for research] (

NLTK data is (C) 2019, NLTK Project. Source: [NLTK] ( Reference: Bird, Steven, Edward Loper and Ewan Klein (2009), Natural Language Processing with Python. O’Reilly Media Inc.


  • Expanded NRC lexicon from approximately 10,000 words to 27,000 based on WordNet synonyms.
  • Minor bug fixes.


Emotional affects measured include the following:

  • fear
  • anger
  • anticipation
  • trust
  • surprise
  • positive
  • negative
  • sadness
  • disgust
  • joy

Sample Usage

from nrclex import NRCLex

#Instantiate text object (for best results, 'text' should be unicode).

text_object = NRCLex('text')

#Return words list.


#Return sentences list.


#Return affect list.


#Return affect dictionary.


#Return raw emotional counts.


#Return highest emotions.


#Return affect frequencies.


Project details

Download files

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

Files for NRCLex, version 2.0.2
Filename, size File type Python version Upload date Hashes
Filename, size NRCLex-2.0.2-py2-none-any.whl (230.8 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size NRCLex-2.0.2.tar.gz (572.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page