Class: WitBot::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/wit_bot/models/outcome.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, raw, i = 0) ⇒ Outcome

Returns a new instance of Outcome.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/wit_bot/models/outcome.rb', line 5

def initialize(message, raw, i=0)
  @message = message
  @raw = raw.with_indifferent_access

  @confidence = @raw[:confidence]
  @_text = @raw[:_text]

  @intent = WitModel::Intent.find raw[:intent]
  @entities = EntityModelProxy.new raw[:entities]

  raise LowConfidenceError self if i == 0 && low_confidence?
end

Instance Attribute Details

#_textObject (readonly)

Returns the value of attribute _text.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def _text
  @_text
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def confidence
  @confidence
end

#entitiesObject (readonly)

Returns the value of attribute entities.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def entities
  @entities
end

#intentObject (readonly)

Returns the value of attribute intent.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def intent
  @intent
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def message
  @message
end

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/wit_bot/models/outcome.rb', line 3

def raw
  @raw
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/wit_bot/models/outcome.rb', line 22

def ==(other)
  self.message == other.message &&
      self.raw == other.raw &&
      self._text == other._text &&
      self.confidence == other.confidence &&
      self.intent == other.intent &&
      self.entities == other.entities
end

#low_confidence?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/wit_bot/models/outcome.rb', line 18

def low_confidence?
  @confidence < WitBot.config.minimum_confidence
end