Class: ClassificationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/engine/classification_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ ClassificationResult

Returns a new instance of ClassificationResult.



5
6
7
8
9
# File 'lib/engine/classification_result.rb', line 5

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

Instance Attribute Details

#overall_probabilityObject

Returns the value of attribute overall_probability.



2
3
4
# File 'lib/engine/classification_result.rb', line 2

def overall_probability
  @overall_probability
end

#sentimentObject

Returns the value of attribute sentiment.



2
3
4
# File 'lib/engine/classification_result.rb', line 2

def sentiment
  @sentiment
end

#textObject

Returns the value of attribute text.



2
3
4
# File 'lib/engine/classification_result.rb', line 2

def text
  @text
end

#token_probabilitiesObject (readonly)

Returns the value of attribute token_probabilities.



3
4
5
# File 'lib/engine/classification_result.rb', line 3

def token_probabilities
  @token_probabilities
end

Instance Method Details

#to_json(*a) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/engine/classification_result.rb', line 11

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