Class: Wit::Result
- Inherits:
-
Object
- Object
- Wit::Result
- Defined in:
- lib/wit/result.rb
Instance Attribute Summary collapse
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intent ⇒ Object
readonly
Returns the value of attribute intent.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(hash) ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wit/result.rb', line 5 def initialize(hash) @id = hash['msg_id'] @text = hash['_text'] outcomes = hash['outcomes'].first if outcomes @intent = outcomes['intent'] @confidence = outcomes['confidence'] @entities = {} outcomes['entities'].each do |name, entity| @entities[name] = entity.map do |e| OpenStruct.new(e) end end end end |
Instance Attribute Details
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
3 4 5 |
# File 'lib/wit/result.rb', line 3 def confidence @confidence end |
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
3 4 5 |
# File 'lib/wit/result.rb', line 3 def entities @entities end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/wit/result.rb', line 3 def id @id end |
#intent ⇒ Object (readonly)
Returns the value of attribute intent.
3 4 5 |
# File 'lib/wit/result.rb', line 3 def intent @intent end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/wit/result.rb', line 3 def text @text end |