Class: Wit::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/wit/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#confidenceObject (readonly)

Returns the value of attribute confidence.



3
4
5
# File 'lib/wit/result.rb', line 3

def confidence
  @confidence
end

#entitiesObject (readonly)

Returns the value of attribute entities.



3
4
5
# File 'lib/wit/result.rb', line 3

def entities
  @entities
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/wit/result.rb', line 3

def id
  @id
end

#intentObject (readonly)

Returns the value of attribute intent.



3
4
5
# File 'lib/wit/result.rb', line 3

def intent
  @intent
end

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'lib/wit/result.rb', line 3

def text
  @text
end