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

Fix inconsistent anticipation key behaviour #5

Closed Starkie closed 3 years ago

Starkie commented 3 years ago

Fixes #2

The key anticipation does not appear when no word related to that emotion is used. 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.

Starkie commented 3 years ago

@metalcorebear Sorry to bother you. Could you review this change, please?

metalcorebear commented 3 years ago

Thanks for doing this! Just merged.