diff --git a/vaderSentiment/vaderSentiment.py b/vaderSentiment/vaderSentiment.py index 615ab75..9f43ad7 100644 --- a/vaderSentiment/vaderSentiment.py +++ b/vaderSentiment/vaderSentiment.py @@ -31,14 +31,14 @@ N_SCALAR = -0.74 NEGATE = \ - ["aint", "arent", "cannot", "cant", "couldnt", "darent", "didnt", "doesnt", + {"aint", "arent", "cannot", "cant", "couldnt", "darent", "didnt", "doesnt", "ain't", "aren't", "can't", "couldn't", "daren't", "didn't", "doesn't", "dont", "hadnt", "hasnt", "havent", "isnt", "mightnt", "mustnt", "neither", "don't", "hadn't", "hasn't", "haven't", "isn't", "mightn't", "mustn't", "neednt", "needn't", "never", "none", "nope", "nor", "not", "nothing", "nowhere", "oughtnt", "shant", "shouldnt", "uhuh", "wasnt", "werent", "oughtn't", "shan't", "shouldn't", "uh-uh", "wasn't", "weren't", - "without", "wont", "wouldnt", "won't", "wouldn't", "rarely", "seldom", "despite"] + "without", "wont", "wouldnt", "won't", "wouldn't", "rarely", "seldom", "despite"} # booster/dampener 'intensifiers' or 'degree adverbs' # http://en.wiktionary.org/wiki/Category:English_degree_adverbs @@ -87,15 +87,9 @@ def negated(input_words, include_nt=True): Determine if input contains negation words """ input_words = [str(w).lower() for w in input_words] - neg_words = [] - neg_words.extend(NEGATE) - for word in neg_words: - if word in input_words: + for word in input_words: + if word in NEGATE or (include_nt and "n't" in word): return True - if include_nt: - for word in input_words: - if "n't" in word: - return True '''if "least" in input_words: i = input_words.index("least") if i > 0 and input_words[i - 1] != "at":