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

NRCLex

(C) 2019 Mark M. Bailey

About

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] (http://sentiment.nrc.ca/lexicons-for-research/)

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

Update

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

Affects

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.

text_object.words

#Return sentences list.

text_object.sentences

#Return affect list.

text_object.affect_list

#Return affect dictionary.

text_object.affect_dict

#Return raw emotional counts.

text_object.raw_emotion_scores

#Return highest emotions.

text_object.top_emotions

#Return affect frequencies.

text_object.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.

Source Distribution

NRCLex-3.0.0.tar.gz (396.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NRCLex-3.0.0-py2-none-any.whl (43.3 kB view details)

Uploaded Python 2

File details

Details for the file NRCLex-3.0.0.tar.gz.

File metadata

  • Download URL: NRCLex-3.0.0.tar.gz
  • Upload date:
  • Size: 396.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.13

File hashes

Hashes for NRCLex-3.0.0.tar.gz
Algorithm Hash digest
SHA256 a4ae80e2b50a1404d6dcf3273b4388d7a3811c20c6c7afa1f91768b2b3cc8fa3
MD5 6cb5417f9ab39b4f23baeec3994a5726
BLAKE2b-256 411c0097ee39d456c8a92b2eb5dfd59f581a09a6bafede184a058fb0f19bb6ea

See more details on using hashes here.

File details

Details for the file NRCLex-3.0.0-py2-none-any.whl.

File metadata

  • Download URL: NRCLex-3.0.0-py2-none-any.whl
  • Upload date:
  • Size: 43.3 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.13.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/2.7.13

File hashes

Hashes for NRCLex-3.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 3e6fa99f1f2293b31a9bfbaf56f87ad9a241abeac13ea2a88e135a41ed3faadf
MD5 9b8b789dbedb42458b2d1c279269f923
BLAKE2b-256 3e4d43b09cecf0581fc75a12b546383553cab984e1ef99d85948a4440c8d5e5e

See more details on using hashes here.

Supported by

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