class Opener::OpinionDetectorBasic::Processor

Class that detects opinions in a given input KAF file.

Public Instance Methods

opinions() click to toggle source
# File lib/opener/opinion_detector_basic/processor.rb, line 8
def opinions
  return @opinions if @opinions

  ##
  # Initialize opinions with their expressions.
  #
  @opinions = document.terms.map do |term|
    next unless term.is_expression? and term.accumulated_strength != 0
    Kaf::Opinion.new term
  end.compact

  set_accumulated_strength
end
set_accumulated_strength() click to toggle source
# File lib/opener/opinion_detector_basic/processor.rb, line 22
def set_accumulated_strength
  terms.each.with_index do |term, i|
    head = term.head_term
    if head.is_shifter?
      term.accumulated_strength *= -1
      term.list_ids += term.list_ids
    elsif head.is_intensifier?
      term.accumulated_strength += head.accumulated_strength
      term.list_ids += term.list_ids
    else
    end
  end
end