lib/opener/opinion_detector_basic/kaf/opinion.rb
##
# Get the potential right and left candidates of the sentence and
# decide which ones are the actual targets of the opinion
#
Get the potential right and left candidates of the sentence and
decide which ones are the actual targets of the opinion
Get the potential right and left candidates of the sentence and decide which ones are the actual targets of the opinion
def obtain_targets(sentences)
          sentence_terms = sentences[sentence]
          max_distance = 3
          terms_count = sentence_terms.count
          index = -1
          sentence_terms.each_with_index do |term, i|
            if ids.include?(term.id)
              index = i
            end
          end
          unless index+1 >= terms_count
            min = index+1
            max = [index+1+max_distance,terms_count].min
            @right_candidates = filter_candidates(sentence_terms[min..max])
          end
          index = 0
          sentence_terms.each_with_index do |term, i|
            if ids.include?(term.id)
              index = i
              break 
            end
          end
          unless index == 0
            min = [0, index-1-max_distance].max
            max = index
            @left_candidates = filter_candidates(sentence_terms[min..max])
          end
          if right_candidates.any?
            @target_ids << right_candidates.first.id
          end
          if left_candidates.any?
            @target_ids << left_candidates.last.id
          end
        end
def obtain_targets ( sentences ) sentence_terms = sentences [ sentence ] max_distance = 3 terms_count = sentence_terms . count index = - 1 sentence_terms . each_with_index do | term , i | if ids . include? ( term . id ) index = i end end unless index + 1 >= terms_count min = index + 1 max = [ index + 1 + max_distance , terms_count ] . min @right_candidates = filter_candidates ( sentence_terms [ min .. max ] ) end index = 0 sentence_terms . each_with_index do | term , i | if ids . include? ( term . id ) index = i break end end unless index == 0 min = [ 0 , index - 1 - max_distance ] . max max = index @left_candidates = filter_candidates ( sentence_terms [ min .. max ] ) end if right_candidates . any? @target_ids << right_candidates . first . id end if left_candidates . any? @target_ids << left_candidates . last . id end end
Get the potential right and left candidates of the sentence and
decide which ones are the actual targets of the opinion
Get the potential right and left candidates of the sentence and decide which ones are the actual targets of the opinion
# needed for left_candidates
sentences
<not_specific>