Class: Watson::ConversationEnhanced

Inherits:
Conversation show all
Defined in:
lib/watson/conversation_enhanced.rb

Instance Method Summary collapse

Methods inherited from Conversation

#build_response, configure, #conversation, #url

Constructor Details

#initialize(intent = '') ⇒ ConversationEnhanced

Returns a new instance of ConversationEnhanced.



4
5
6
# File 'lib/watson/conversation_enhanced.rb', line 4

def initialize(intent = '')
  @intent = intent
end

Instance Method Details

#must_retrieve?(result) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/watson/conversation_enhanced.rb', line 18

def must_retrieve?(result)
  result == @intent
end

#retrieve_and_rank(message) ⇒ Object



22
23
24
# File 'lib/watson/conversation_enhanced.rb', line 22

def retrieve_and_rank(message)
  RetrieveAndRank.send_message(message)
end

#send_message(message = '') ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/watson/conversation_enhanced.rb', line 8

def send_message(message = '')
  return if message.empty?
  response = super
  if must_retrieve?(response[:intent])
    retrieve_and_rank(message)
  else
    response
  end
end