Class: VaderSentimentRuby::Checker::LeastWordNegationChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/vader_sentiment_ruby/checker/least_word_negation_checker.rb

Overview

Checks for negation case using “least”

Instance Method Summary collapse

Constructor Details

#initialize(valence, words_and_emoticons, index, lexicon) ⇒ LeastWordNegationChecker

Returns a new instance of LeastWordNegationChecker.



7
8
9
10
11
12
# File 'lib/vader_sentiment_ruby/checker/least_word_negation_checker.rb', line 7

def initialize(valence, words_and_emoticons, index, lexicon)
  @valence = valence
  @words_and_emoticons = words_and_emoticons
  @index = index
  @lexicon = lexicon
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vader_sentiment_ruby/checker/least_word_negation_checker.rb', line 14

def call
  valence = @valence
  return valence unless !word_in_lexicon?(@index - 1) && word_is?(@index - 1, 'least')

  if @index > 1
    valence *= Constants::N_SCALAR if !word_is?(@index - 2, 'at') && !word_is?(@index - 2, 'very')
  elsif @index.positive?
    valence *= Constants::N_SCALAR
  end

  valence
end