Class: VaderSentimentRuby::Checker::NegationChecker

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

Overview

Checks for negation

Instance Method Summary collapse

Constructor Details

#initialize(valence, words_and_emoticons, start_index, index) ⇒ NegationChecker

Returns a new instance of NegationChecker.

Parameters:

  • valence (Float)
  • words_and_emoticons (Array(String))
  • start_index (Integer)
  • index (Integer)


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

def initialize(valence, words_and_emoticons, start_index, index)
  @valence = valence
  @words_and_emoticons_lower = words_and_emoticons.map { |word| word.to_s.downcase }
  @start_index = start_index
  @index = index
end

Instance Method Details

#callFloat

Returns:

  • (Float)


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

def call
  valence = @valence
  valence = check_zero_index(valence) if @start_index.zero?
  valence = check_first_index(valence) if @start_index == 1
  valence = check_second_index(valence) if @start_index == 2

  valence
end