Class: VaderSentimentRuby::Checker::LeastWordNegationChecker
- Inherits:
-
Object
- Object
- VaderSentimentRuby::Checker::LeastWordNegationChecker
- Defined in:
- lib/vader_sentiment_ruby/checker/least_word_negation_checker.rb
Overview
Checks for negation case using “least”
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(valence, words_and_emoticons, index, lexicon) ⇒ LeastWordNegationChecker
constructor
A new instance of LeastWordNegationChecker.
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
#call ⇒ Object
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 |