Class: DucklingService::Response

Inherits:
Object
  • Object
show all
Defined in:
src/services/duckling_service.rb

Overview

Describes a duckling response

Instance Method Summary collapse

Instance Method Details

#parses?Boolean

Check if there are parses discovered

A parse is a substring of the original text that has an extracted meaning.

Returns:

  • (Boolean)


59
60
61
# File 'src/services/duckling_service.rb', line 59

def parses?
  @parses.size > 0
end

#single_parse?Boolean

Check if there is a single parse

A parse is a substring of the original text that has an extracted meaning.

Returns:

  • (Boolean)


68
69
70
# File 'src/services/duckling_service.rb', line 68

def single_parse?
  @parses.size == 1
end

#timeDucklingService::TimeResponse

The extracted times from all of the parses



75
76
77
78
# File 'src/services/duckling_service.rb', line 75

def time
  # TODO: Can there be multiple time parses?
  @time ||= TimeResponse.new @parses.find { |parse| parse['dim'] == 'time' }
end