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
-
#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 17 18 19 20 21 22 23 24 25 |
# File 'lib/wit_bot/models/outcome.rb', line 5 def initialize(, raw, i=0) = @raw = raw.with_indifferent_access @confidence = @raw[:confidence] @_text = @raw[:_text] @intent = WitModel::Intent.find raw[:intent] @entities = @raw[:entities].each.inject({}) do |entities, entity_info| role, all = entity_info all = all.map { |data| WitModel::Entity.find(data[:entity], create: false).model role, data } data = all.shift data.others = all entities[role] = data entities end.with_indifferent_access 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 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
#low_confidence? ⇒ Boolean
27 28 29 |
# File 'lib/wit_bot/models/outcome.rb', line 27 def low_confidence? @confidence < WitBot.config.minimum_confidence end |