metalcorebear / NRCLex

An affect generator based on TextBlob and the NRC affect lexicon. Note that lexicon license is for research purposes only.
MIT License
66 stars 39 forks source link

Inconsistent behavior with the anticipation behavior #2

Closed el-grudge closed 3 years ago

el-grudge commented 4 years ago

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?

Starkie commented 3 years ago

It seems to be related to how the keys of the frequencies are handled:

First, the anticip key is always present, since it is in the affect_percent dict. But it is never used. https://github.com/metalcorebear/NRCLex/blob/5d66076ad897a2c9406d6c2a3b3d7b7cb3b25644/nrclex.py#L26

The anticipation key is added instead through the frequencies collection.

The key is added here: https://github.com/metalcorebear/NRCLex/blob/5d66076ad897a2c9406d6c2a3b3d7b7cb3b25644/nrclex.py#L23-L24

And it is added to the affect_frequencies here https://github.com/metalcorebear/NRCLex/blob/5d66076ad897a2c9406d6c2a3b3d7b7cb3b25644/nrclex.py#L28-L29

Replacing the anticip key by anticipation should fix it.