Class: VaderSentimentRuby::Checker::PreviousWordsInfluenceChecker

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

Overview

Checks if the preceding words increase, decrease, or negate/nullify the valence

Instance Method Summary collapse

Constructor Details

#initialize(word, valence, is_cap_diff) ⇒ PreviousWordsInfluenceChecker

Returns a new instance of PreviousWordsInfluenceChecker.

Parameters:

  • word (String)
  • valence (Float)
  • is_cap_diff (Boolean)


10
11
12
13
14
15
16
# File 'lib/vader_sentiment_ruby/checker/previous_words_influence_checker.rb', line 10

def initialize(word, valence, is_cap_diff)
  @word = word
  @word_lower = word.downcase
  @valence = valence
  @is_cap_diff = is_cap_diff
  @scalar = 0.0
end

Instance Method Details

#callFloat

Returns:

  • (Float)


19
20
21
22
23
24
25
26
27
# File 'lib/vader_sentiment_ruby/checker/previous_words_influence_checker.rb', line 19

def call
  return @scalar unless word_in_booster_dictionary?

  take_scalar_from_dictionary
  @scalar *= -1 if @valence.negative?
  amplify_scalar_by_word_case

  @scalar
end