cjhutto / vaderSentiment

VADER Sentiment Analysis. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media, and works well on texts from other domains.
MIT License
4.43k stars 1k forks source link

A serious error in the program #74

Closed kchen032 closed 5 years ago

kchen032 commented 5 years ago

In Line 264:

    for item in words_and_emoticons:
        valence = 0
        i = words_and_emoticons.index(item)

This is unfortunately wrong. Take the following sentence as an example:

    words_and_emoticions = ['this', 'wasn't', 'good', 'that', 'was', 'good']

The first 'good' was negative when doing the negation check. However, when the program goes to the second 'good',

    i = words_and_emoticons.index(item)

will point to the index of the first 'good' and thus incorrectly return a negative count. Many issues found by other users are related to this coding error.

A solution would be:

    for i in range(0, len(words_and_emoticons)):
        then use words_and_emoticons[i] to loop through all words.
cjhutto commented 5 years ago

Corrected