class BasicEmotions

@note This class analyze basic emotions @return [Array] of expanded basic emotions to complex emotions

Attributes

keywords[R]
text[R]

Public Class Methods

call(keywords, text) click to toggle source

@note This method initializes class

# File lib/artemo/basic_emotions.rb, line 9
def self.call(keywords, text)
  @keywords = keywords
  @text = text
  sum_array = compare
  scaled_array = scale(sum_array)
  checked_array = check(scaled_array)
  weighed_array = weigh(scaled_array, checked_array)
  scale(weighed_array)
end

Private Class Methods

compare() click to toggle source

@note This method compare two words, if word is in array text then add one.

# File lib/artemo/basic_emotions.rb, line 22
def self.compare
  sum_array = Array.new(8).fill(0)
  @keywords.each.with_index do |line, index|
    line.each do |keyword|
      sum_array[index] += 1 if @text.include?(keyword)
    end
  end
  sum_array
end