Class: VaderSentimentRuby::Checker::ButWordNegationChecker
- Inherits:
-
Object
- Object
- VaderSentimentRuby::Checker::ButWordNegationChecker
- Defined in:
- lib/vader_sentiment_ruby/checker/but_word_negation_checker.rb
Overview
Checks for modification in sentiment due to contrastive conjunction ‘but’
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(words_and_emoticons, sentiments) ⇒ ButWordNegationChecker
constructor
A new instance of ButWordNegationChecker.
Constructor Details
#initialize(words_and_emoticons, sentiments) ⇒ ButWordNegationChecker
Returns a new instance of ButWordNegationChecker.
7 8 9 10 |
# File 'lib/vader_sentiment_ruby/checker/but_word_negation_checker.rb', line 7 def initialize(words_and_emoticons, sentiments) @words_and_emoticons_lower = words_and_emoticons.map { |w| w.to_s.downcase } @sentiments = sentiments end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/vader_sentiment_ruby/checker/but_word_negation_checker.rb', line 12 def call return @sentiments unless @words_and_emoticons_lower.include?('but') but_index = @words_and_emoticons_lower.index('but') updated_sentiments = [] @sentiments.each_with_index do |sentiment, senti_index| updated_sentiments << modified_sentiment(sentiment, senti_index, but_index) end updated_sentiments end |