Skip to main content

NRCLex

(C) 2019 Mark M. Bailey, PhD

About

NRCLex measures emotional affect from text. Affect dictionary contains approximately 27,000 words and is based on the National Research Council Canada (NRC) affect lexicon and NLTK WordNet synonym sets.

Lexicon source is (C) 2016 National Research Council Canada (NRC) and this package is for research purposes only. Source: http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm As per the terms of use of the NRC Emotion Lexicon, if you use the lexicon or any derivative from it, cite this paper: Crowdsourcing a Word-Emotion Association Lexicon, Saif Mohammad and Peter Turney, Computational Intelligence, 29 (3), 436-465, 2013.

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.

Installation

pip install NRCLex

Affects

Emotional affects measured include:

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

Sample Usage

from nrclex import NRCLex

Instantiate NRCLex object. By default this loads the bundled lexicon packaged with the library:

text_object = NRCLex()

You can pass your raw text to this method (for best results, text should be unicode):

text_object.load_raw_text(text: str)

You can pass already tokenized text as a list of tokens. This usage does not require TextBlob tokenization:

text_object.load_token_list(list_of_tokens: list)

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

Release files for NRCLex 4.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for NRCLex 4.1.0
File Size Uploaded
nrclex-4.1.0.tar.gz 44.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for NRCLex 4.1.0
File Interpreter ABI Platform
nrclex-4.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 88.6 kB

Release files / nrclex-4.1.0.tar.gz

Download URL nrclex-4.1.0.tar.gz
Size 44.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0fdf04b0b59bf48d8006ac3f96bfda9bfe55a2a31300326fe345ecd35b6ba4a2
BLAKE2b-256 checksum
How to use checksums
1ea67218aacd34b4f7b426df240d3d4d67bc35ae5ec9a25f58bf20b1bb871fb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / nrclex-4.1.0-py3-none-any.whl

Download URL nrclex-4.1.0-py3-none-any.whl
Size 44.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61d68d09cd6cddf7f2c4ad12d2b5ea13d376a75bf38c7f96ff306e112e96a386
BLAKE2b-256 checksum
How to use checksums
2d15339ce55f38f9a4309a9db6600cdce878e1d45d5cc1d04e869fa720a8b2fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

4.1.0 This release

2 release files

4.0

1 release file

3.0.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page