Sha256: 927618e2cecae5f5ab63df91c9ad774bb3eeffd7a2355dbfc88248d7e1674644

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

class ClassificationResult
  attr_accessor :text, :overall_probability, :sentiment
  attr_reader :token_probabilities

  def initialize text
    @text = text
    @token_probabilities = []
    @sentiment = Sentiment::NEUTRAL
  end

  def to_json(*a)
    {
      text:        @text,
      probability: @overall_probability,
      sentiment:   @sentiment
    }.to_json(*a)
  end

end

class TokenProbability
  attr_accessor :token, :probability, :sentiment, :positive_total,
    :positive_matches, :negative_total, :negative_matches

  def initialize token, probability, sentiment, positive_total, positive_matches, negative_total, negative_matches
    @token, @probability, @sentiment, @positive_total, @positive_matches, @negative_total, @negative_matches = token, probability, sentiment, positive_total, positive_matches, negative_total, negative_matches
  end
end

class Sentiment
  POSITIVE = ':)'
  NEGATIVE = ':('
  NEUTRAL  = ':|'
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sentimentalizer-0.3.2 lib/engine/classification_result.rb
sentimentalizer-0.3.1 lib/engine/classification_result.rb
sentimentalizer-0.3.0 lib/engine/classification_result.rb
sentimentalizer-0.2.2 lib/engine/classification_result.rb
sentimentalizer-0.2.1 lib/engine/classification_result.rb
sentimentalizer-0.1.0 lib/engine/classification_result.rb