Class: WitBot::Outcome
- Inherits:
-
Object
- Object
- WitBot::Outcome
- Defined in:
- lib/wit_bot/models/outcome.rb
Instance Attribute Summary collapse
-
#_text ⇒ Object
readonly
Returns the value of attribute _text.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#intent ⇒ Object
readonly
Returns the value of attribute intent.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(message, raw, i = 0) ⇒ Outcome
constructor
A new instance of Outcome.
- #low_confidence? ⇒ Boolean
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(, raw, i=0) @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
#_text ⇒ Object (readonly)
Returns the value of attribute _text.
3 4 5 |
# File 'lib/wit_bot/models/outcome.rb', line 3 def _text @_text end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
3 4 5 |
# File 'lib/wit_bot/models/outcome.rb', line 3 def confidence @confidence end |
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
3 4 5 |
# File 'lib/wit_bot/models/outcome.rb', line 3 def entities @entities end |
#intent ⇒ Object (readonly)
Returns the value of attribute intent.
3 4 5 |
# File 'lib/wit_bot/models/outcome.rb', line 3 def intent @intent end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/wit_bot/models/outcome.rb', line 3 def @message end |
#raw ⇒ Object (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. == other. && self.raw == other.raw && self._text == other._text && self.confidence == other.confidence && self.intent == other.intent && self.entities == other.entities end |
#low_confidence? ⇒ Boolean
18 19 20 |
# File 'lib/wit_bot/models/outcome.rb', line 18 def low_confidence? @confidence < WitBot.config.minimum_confidence end |