ibm-watson-ruby 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b0c86b0b88c44a474376bd43b2e110b7754eaf6
4
- data.tar.gz: 3893a7d6cde18e060f477c3ca86e0c4fb05934d1
3
+ metadata.gz: 3d3195bcccad976df212074781bf31e7fb7294f2
4
+ data.tar.gz: 53ae05cbe93970afd40ac57f370637c598c532bd
5
5
  SHA512:
6
- metadata.gz: 10a8affa0eebe3ee715faea64bb6971ffe5510792c52dc778f28bebcf9dde7276c067d634275cb1d82462d5ad29903171f5abb247761089cc8e8f3609489dfd9
7
- data.tar.gz: fa69dfa4a1759f60ff34ca9749aabc11664f273b0650b9e48bd658031289290a0e6a4d01abd848a88a860d9a4baf9cd675984dac9c3eba4fcd816b7bbd12cbd5
6
+ metadata.gz: '09568b6872472b87bcbb9a397b0ba3ea08098f2e07cfe256168d29f434fb96d5dd5016ba96f8d9f7381d3f900d8f1b26cbc4769d141761df222b2d4194eda9cb'
7
+ data.tar.gz: 7784a1b32ca4976ed65def28915db96057b6f44c9f8cbb62daf5f2312ae0f35f0292b1bb9576119cdb86973197cc86a90740af7627724eab3ff7494e3c0aa029
data/.env.example ADDED
@@ -0,0 +1,10 @@
1
+ # Use your own credentials
2
+ IBM_WATSON_CONVERSATION_USERNAME=xxx
3
+ IBM_WATSON_CONVERSATION_PASSWORD=yyy
4
+
5
+ # the VCR examples kinda need this workspace id to match
6
+ IBM_WATSON_WORKSPACE_ID=9c9b5bb9-9841-4c08-a69b-1af8797c74c8
7
+ IBM_WATSON_WORKSPACE_ID_TO_DELETE=c6f27505-bc6c-4914-bd8d-b570d8ff2720
8
+
9
+ IBM_WATSON_NLU_USERNAME=xxx
10
+ IBM_WATSON_NLU_PASSWORD=yyy
data/Gemfile CHANGED
@@ -2,14 +2,3 @@ source 'https://rubygems.org'
2
2
  ruby "~> 2.3.0"
3
3
 
4
4
  gemspec
5
-
6
- gem 'http'
7
- gem 'active_attr'
8
-
9
- group :test, :development do
10
- gem 'dotenv'
11
- gem 'rspec'
12
- gem 'rspec-middlewares'
13
- gem 'vcr'
14
- gem 'webmock'
15
- end
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency "http", "~> 2.0"
22
22
  gem.add_dependency "active_attr", '~> 0.10'
23
23
  gem.add_dependency "active_attr_extended", "~> 0.9"
24
+ gem.add_dependency "activesupport"
24
25
 
25
26
  gem.add_development_dependency 'bundler', '~> 1.0'
26
27
  gem.add_development_dependency 'rake', '~> 0.8'
@@ -28,4 +29,7 @@ Gem::Specification.new do |gem|
28
29
  gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
29
30
  gem.add_development_dependency 'rspec-middlewares'
30
31
  gem.add_development_dependency 'vcr'
32
+ gem.add_development_dependency 'webmock'
33
+ gem.add_development_dependency 'dotenv'
34
+ gem.add_development_dependency 'pry'
31
35
  end
data/lib/ibm_watson.rb CHANGED
@@ -1,8 +1,16 @@
1
1
  require 'active_attr'
2
2
  require 'active_attr_extended'
3
3
 
4
- require 'ibm_watson/version'
5
- require 'ibm_watson/base_model'
6
- require 'ibm_watson/base_service'
7
- require 'ibm_watson/errors'
8
- require 'ibm_watson/conversation'
4
+ require 'active_support'
5
+
6
+ module IBMWatson
7
+ extend ActiveSupport::Autoload
8
+
9
+ autoload :VERSION
10
+ autoload :BaseModel
11
+ autoload :BaseService
12
+ autoload :Errors
13
+
14
+ autoload :Conversation
15
+ autoload :NLU
16
+ end
@@ -2,5 +2,38 @@ module IBMWatson
2
2
  class BaseModel
3
3
  include ActiveAttr::Model
4
4
  include ActiveAttr::AttributeDefaults
5
+
6
+ # Support "Collection" attributes, eg:
7
+ # attribute :foo, type: [String]
8
+ def typecaster_for(type)
9
+ if type.kind_of?(Array) && type.length == 1 && type.first.is_a?(Class)
10
+ item_type = type.first
11
+ lambda do |value|
12
+ value.map { |item|
13
+ unless item.is_a?(item_type)
14
+ item = item_type.new(item)
15
+ end
16
+ item
17
+ }
18
+ end
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ # By default add all collection attributes are considered as if they were associations
25
+ # this will make sure that `as_json` is called on them properly
26
+ def as_json(options = nil)
27
+ options ||= {}
28
+ options[:include] = self.class.collection_attribute_names
29
+ super(options)
30
+ end
31
+
32
+ # All [BaseModel] typed attributes are considered here
33
+ def self.collection_attribute_names
34
+ attributes.select { |name, attribute|
35
+ attribute[:type].present? && attribute[:type].is_a?(Array) && attribute[:type].first <= BaseModel
36
+ }.map { |name, attribute| name }
37
+ end
5
38
  end
6
39
  end
@@ -1,11 +1,12 @@
1
1
  module IBMWatson
2
2
  module Conversation
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Service
6
+ autoload :MessageResponse
7
+ autoload :RuntimeIntent
8
+ autoload :Intent
9
+ autoload :DialogNode
10
+ autoload :Workspace
3
11
  end
4
12
  end
5
-
6
- require_relative 'conversation/service'
7
- require_relative 'conversation/intent_result'
8
- require_relative 'conversation/result'
9
- require_relative 'conversation/intent'
10
- require_relative 'conversation/dialog_node'
11
- require_relative 'conversation/workspace'
@@ -4,7 +4,7 @@ module IBMWatson
4
4
  attribute :intent, type: String
5
5
  attribute :created, type: String
6
6
  attribute :updated, type: String
7
- attribute :examples, type: Array
7
+ attribute :examples, type: [Hash]
8
8
  attribute :description
9
9
  end
10
10
  end
@@ -0,0 +1,12 @@
1
+ module IBMWatson
2
+ module Conversation
3
+ class MessageResponse < IBMWatson::BaseModel
4
+ attribute :entities, type: [RuntimeEntity]
5
+ attribute :input
6
+ attribute :output
7
+ attribute :context
8
+ attribute :alternate_intents
9
+ attribute :intents, type: [RuntimeIntent]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module IBMWatson
2
+ module Conversation
3
+ class RuntimeEntity < IBMWatson::BaseModel
4
+ attribute :entity, type: String
5
+ attribute :location, type: [Integer]
6
+ attribute :value, type: String
7
+ attribute :confidence, type: Float
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,6 @@
1
1
  module IBMWatson
2
2
  module Conversation
3
- class IntentResult < IBMWatson::BaseModel
3
+ class RuntimeIntent < IBMWatson::BaseModel
4
4
  attribute :intent, type: String
5
5
  attribute :confidence, type: Float
6
6
  end
@@ -30,7 +30,7 @@ module IBMWatson
30
30
  end
31
31
 
32
32
  def delete_workspace(workspace_id:)
33
- url = build_url('workspaces', workspace_id, query: { version: QUERY_VERSION})
33
+ url = build_url('workspaces', workspace_id, query: { version: QUERY_VERSION })
34
34
  result = accept_json(basic_auth).delete(url)
35
35
  verify_http_result(result)
36
36
  end
@@ -49,7 +49,7 @@ module IBMWatson
49
49
  }
50
50
  result = accept_json(basic_auth).post(url, json: params)
51
51
  verify_http_result(result)
52
- IBMWatson::Conversation::Result.new.tap do |result_object|
52
+ IBMWatson::Conversation::MessageResponse.new.tap do |result_object|
53
53
  result_object.from_json(result)
54
54
  end
55
55
  end
@@ -9,12 +9,10 @@ module IBMWatson
9
9
  attribute :updated, type: String
10
10
  attribute :workspace_id, type: String
11
11
  attribute :status, type: String
12
- attribute :intents, type: ::IBMWatson::Conversation::Intent,
13
- typecaster: lambda { |values| values.map { |value| ::IBMWatson::Conversation::Intent.new(value) }}
14
- attribute :entities, type: Array
15
- attribute :counterexamples, type: Array
16
- attribute :dialog_nodes, type: ::IBMWatson::Conversation::DialogNode,
17
- typecaster: lambda { |values| values.map { |value| ::IBMWatson::Conversation::DialogNode.new(value)}}
12
+ attribute :intents, type: [Intent]
13
+ attribute :entities, type: [Hash]
14
+ attribute :counterexamples, type: [Hash]
15
+ attribute :dialog_nodes, type: [DialogNode]
18
16
  end
19
17
  end
20
18
  end
@@ -1,7 +1,12 @@
1
1
  module IBMWatson
2
2
  module Errors
3
- class WatsonError < StandardError; end
4
- class WatsonRequestError < WatsonError; end
5
- class WatsonServerError < WatsonError; end
3
+ class WatsonError < StandardError
4
+ end
5
+
6
+ class WatsonRequestError < WatsonError
7
+ end
8
+
9
+ class WatsonServerError < WatsonError
10
+ end
6
11
  end
7
12
  end
@@ -0,0 +1,8 @@
1
+ module IBMWatson
2
+ module NLU
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Service
6
+ autoload :AnalyzeResult
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ module IBMWatson
2
+ module NLU
3
+ class AnalyzeResult < IBMWatson::BaseModel
4
+ class Keyword < IBMWatson::BaseModel
5
+ attribute :text, type: String
6
+ attribute :relevance, type: Float
7
+ end
8
+
9
+ attribute :language, type: String
10
+ attribute :analyzed_text, type: String
11
+ attribute :retrieved_url, type: String
12
+ attribute :usage # no examples of this, so don't know type
13
+
14
+ attribute :concepts, type: [Hash]
15
+ attribute :categories, type: [Hash]
16
+ attribute :emotion, type: Hash
17
+ attribute :entities, type: [Hash]
18
+ attribute :keywords, type: [Keyword]
19
+ attribute :metadata, type: Hash
20
+ attribute :relations, type: [Hash]
21
+ attribute :semantic_roles, type: [Hash]
22
+ attribute :sentiment, type: Hash
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module IBMWatson
2
+ module NLU
3
+ class Service < IBMWatson::BaseService
4
+ version "v1"
5
+ url "https://gateway.watsonplatform.net/natural-language-understanding/api"
6
+ QUERY_VERSION = "2017-02-27"
7
+
8
+ class FeatureDefinition
9
+
10
+ end
11
+
12
+ def analyze_text(text, language: 'en', keywords: false)
13
+ # additional parameters not being implemented:
14
+ # - html (analyzing html)
15
+ # - url (analyzing urls)
16
+ # - clean (not sure what it does yet)
17
+
18
+ features = {}
19
+ features[:keywords] = {} if keywords
20
+ # Features not implemented yet:
21
+ # - concepts
22
+ # - categories
23
+ # - emotion
24
+ # - entities
25
+ # - metadata
26
+ # - relations
27
+ # - semantic_roles
28
+ # - sentiment
29
+
30
+ parameters = {
31
+ text: text,
32
+ language: language,
33
+ # return_analyzed_text: true,
34
+ features: features,
35
+ }
36
+
37
+ url = build_url('analyze', query: { version: QUERY_VERSION })
38
+ result = accept_json(basic_auth).post(url, json: parameters)
39
+
40
+ verify_http_result(result)
41
+
42
+ IBMWatson::NLU::AnalyzeResult.new.tap do |result_object|
43
+ result_object.from_json(result)
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module IBMWatson
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,3 @@
1
+ # This is just a stub to help rubygems find the include file on its own
2
+
3
+ require_relative 'ibm_watson'
@@ -2,14 +2,11 @@ require 'spec_helper'
2
2
  require 'ibm_watson'
3
3
 
4
4
  describe IBMWatson::Conversation::Service, record: :none do
5
- subject(:service) { described_class.new(username: username, password: password) }
6
5
  let(:username) { ENV['IBM_WATSON_CONVERSATION_USERNAME'] }
7
6
  let(:password) { ENV['IBM_WATSON_CONVERSATION_PASSWORD'] }
8
7
  let(:workspace_id) { ENV['IBM_WATSON_WORKSPACE_ID'] }
9
8
  let(:delete_workspace_id) { ENV['IBM_WATSON_WORKSPACE_ID_TO_DELETE'] }
10
- subject(:service) do
11
- described_class.new(username: username, password: password)
12
- end
9
+ subject(:service) { described_class.new(username: username, password: password) }
13
10
 
14
11
  describe "#message" do
15
12
  before do
@@ -40,7 +37,7 @@ describe IBMWatson::Conversation::Service, record: :none do
40
37
 
41
38
  example do
42
39
  result = subject.message(workspace_id: workspace_id, input: "Awesome!", context: context)
43
- expect(result.intents.first).to be_a_kind_of(IBMWatson::Conversation::IntentResult)
40
+ expect(result.intents.first).to be_a_kind_of(IBMWatson::Conversation::RuntimeIntent)
44
41
  expect(result.intents.as_json).to eq expected_intents
45
42
  expect(result.context).to be_a_kind_of(Hash)
46
43
  expect(result.context.as_json).to eq(expected_context_json)
@@ -94,9 +91,7 @@ describe IBMWatson::Conversation::Service, record: :none do
94
91
 
95
92
  describe "#delete_workspace" do
96
93
  example do
97
- expect {
98
- subject.delete_workspace(workspace_id: delete_workspace_id)
99
- }.not_to raise_error
94
+ subject.delete_workspace(workspace_id: delete_workspace_id)
100
95
  end
101
96
  end
102
97
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'ibm_watson'
3
+
4
+ describe IBMWatson::NLU::Service, record: :once do
5
+ subject(:service) { described_class.new(username: username, password: password) }
6
+ let(:username) { ENV['IBM_WATSON_NLU_USERNAME'] }
7
+ let(:password) { ENV['IBM_WATSON_NLU_PASSWORD'] }
8
+
9
+ describe "keyword extraction" do
10
+ example do
11
+ result = service.analyze_text("sure, I'll bite. My name is Kieran", keywords: true)
12
+
13
+ expect(result.keywords).to be_a_kind_of(Array)
14
+ expect(result.keywords.length).to eq(1)
15
+ expect(result.keywords[0].as_json).to eq({ "relevance" => 0.970239, "text" => "Kieran" })
16
+ end
17
+ end
18
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,5 @@
1
- require 'rspec'
2
- require 'middleware'
3
- require 'rspec-middlewares'
4
- require 'vcr'
1
+ require 'bundler/setup'
2
+ Bundler.require :default, :development
5
3
  require 'dotenv/load'
6
4
 
7
5
  RSpec.configure do |config|
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/9c9b5bb9-9841-4c08-a69b-1af8797c74c8?export=true&version=2017-02-03
5
+ uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/c6f27505-bc6c-4914-bd8d-b570d8ff27208?export=true&version=2017-02-03
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -68,7 +68,7 @@ http_interactions:
68
68
  recorded_at: Thu, 06 Apr 2017 22:45:40 GMT
69
69
  - request:
70
70
  method: get
71
- uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/80738bb6-bc71-433a-b0b4-88f15ee01b3b?export=true&version=2017-02-03
71
+ uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/c6f27505-bc6c-4914-bd8d-b570d8ff2720?export=true&version=2017-02-03
72
72
  body:
73
73
  encoding: US-ASCII
74
74
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: delete
5
- uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/e8c1caa7-2e28-4c7c-be5a-5422c420c899?version=2017-02-03
5
+ uri: https://gateway.watsonplatform.net/conversation/api/v1/workspaces/c6f27505-bc6c-4914-bd8d-b570d8ff2720?version=2017-02-03
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -242,7 +242,7 @@ http_interactions:
242
242
  how I am","previous_sibling":"Say hello"},{"go_to":null,"output":{"text":{"values":["Sure.
243
243
  Sounds good.","Okay. No problem.","Glad to hear it."],"selection_policy":"random"}},"parent":null,"context":null,"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"#no_problem","description":null,"dialog_node":"Tell
244
244
  me everything is okay","previous_sibling":"Asks a property question"},{"go_to":null,"output":{"choices":{"choices":[{"body":"Like
245
- this?"}],"template":"realtor/intro_question_one"},"template":"realtor/intro"},"parent":null,"context":{"introduced":true,"initial_question":"\u003c?input.text?\u003e"},"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"$introduced
245
+ this?"}],"template":"realtor/intro_question_one"},"template":"realtor/intro"},"parent":null,"context":{"introduced":true,"initial_question":"<?input.text?>"},"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"$introduced
246
246
  == false","description":null,"dialog_node":"Introduce the Bot","previous_sibling":"Ask
247
247
  who I am"},{"go_to":{"return":null,"selector":"body","dialog_node":"Clear
248
248
  initial question"},"output":{"text":{"values":["Sure! You asked ''$initial_question'',
@@ -264,7 +264,7 @@ http_interactions:
264
264
  approve. I''m ready for your questions now."],"selection_policy":"sequential"}},"parent":"Like
265
265
  that.","context":null,"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"#thumbs_down","description":null,"dialog_node":"Thumbs
266
266
  Down","previous_sibling":"Thumbs Up"},{"go_to":{"return":null,"selector":"condition","dialog_node":"Talk
267
- to my boss"},"output":{"message_template":"realtor/intro"},"parent":null,"context":{"listing":"none","introduced":false,"initial_question":"\u003c?input.text?\u003e"},"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"conversation_start","description":null,"dialog_node":"Conversation
267
+ to my boss"},"output":{"message_template":"realtor/intro"},"parent":null,"context":{"listing":"none","introduced":false,"initial_question":"<?input.text?>"},"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"conversation_start","description":null,"dialog_node":"Conversation
268
268
  Starts","previous_sibling":null},{"go_to":{"return":null,"selector":"condition","dialog_node":"Talk
269
269
  to my boss"},"output":{"text":{"values":[],"selection_policy":"sequential"}},"parent":"Introduce
270
270
  the Bot","context":null,"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"#talk_to_my_boss","description":null,"dialog_node":"Talk
@@ -297,7 +297,7 @@ http_interactions:
297
297
  I''ll search for @property-type less than than @sys-number for you. Might
298
298
  be a few minutes."],"selection_policy":"sequential"}},"parent":"Ask about
299
299
  homes","context":null,"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"@property-type:home
300
- \u0026\u0026 @under-filter:under \u0026\u0026 @sys-number","description":null,"dialog_node":"node_4_1489443566378","previous_sibling":"node_8_1489424344276"},{"type":"response_condition","go_to":null,"output":{"text":{"values":["The
300
+ && @under-filter:under && @sys-number","description":null,"dialog_node":"node_4_1489443566378","previous_sibling":"node_8_1489424344276"},{"type":"response_condition","go_to":null,"output":{"text":{"values":["The
301
301
  home I have for sale is 3520 willows road."],"selection_policy":"sequential"}},"parent":"Ask
302
302
  about homes","context":null,"created":"2017-03-25T00:48:38.808Z","updated":"2017-03-25T00:48:38.808Z","metadata":null,"conditions":"
303
303
  @property-type:home","description":null,"dialog_node":"node_9_1489424359166","previous_sibling":"node_4_1489443566378"},{"type":"response_condition","go_to":null,"output":{"text":{"values":["Yes,
@@ -0,0 +1,66 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2017-02-27
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"text":"sure, I''ll bite. My name is Kieran","language":"en","features":{"keywords":{}}}'
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Connection:
13
+ - close
14
+ Content-Type:
15
+ - application/json; charset=UTF-8
16
+ Host:
17
+ - gateway.watsonplatform.net
18
+ User-Agent:
19
+ - http.rb/2.2.1
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Backside-Transport:
26
+ - OK OK
27
+ Connection:
28
+ - close
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Date:
32
+ - Thu, 13 Apr 2017 19:45:28 GMT
33
+ X-Request-Id:
34
+ - n06mov7ud0bcnk7r66n8341l8ktt3skt
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ Content-Type:
38
+ - application/json;charset=utf-8
39
+ Server:
40
+ - "-"
41
+ Set-Cookie:
42
+ - Watson-DPAT=qzhOiFUiHa7cAHj4sTZsl1E7IgiZ2OJf30q9zfLpP8%2FwxM5Db9jOyL6qKc4VgIWphye%2FDOLsNeNUS5eVoQxx8tM%2BfI%2BLtMHl831DouJrmWKMEqFRUC0oYt8PrOtAp%2BhL2rBgIzb30egtL733g4WbzH7B5ZUuznEehmsPCHZO8G9UNT39dr7YtNcrmQAVaOKp4ZRuBlshu%2Fxrcp94hsKdc%2BsCe4hsNXFH64DM9HhPig4SbnYLy4EhfPQCpn9Of17LEJnl5LUOA%2FpJ43x72QjvcA%2F1qL%2BZvNGAp00oLvxHulOlCRw1LJHE%2FekQgehQTIZHzxYNcg7YVzcq9zak%2B4D63lZ0cBR3z8MMlrYnXTqpBQC16VVG%2F1PrPwP8uhl93VXwiyN%2FQtKbyifcAPKriOvXzKDX93e5agPp6sotply9X%2B%2Bry01teq4qO9rCtafOLJiXcwRzqfIbv4%2FMS7fTjkmWvrikwHlWSJlQup9mIVcuJMpkC6YKtuFvdLPRe9ANQ7jsplvLTdOyUL9hTwy8logTTEhflRwPNwkjZ%2BkQ2zvzxXneGu8HAAmyzl4u8XtzcWVdrG6X6Xs4rFdwyqKnPq2Tfl2iqHp7x5rVwPmO5SklqU5so%2BgAehpLM34uDm5CRviNHlMtBKKFLPpHxoiR85zQTlKez01gPf3AjX8pXJ2sU%2B4bcUfsILUXTY1SIFzz3boZaXZPlLsa%2BJJzb2NTWbbENiWN9nJPiMFUx1REVA1u%2BVxeegCaajUbCq2a85M%2B1RNMoGmCDrRNnU9jpiinmMEw%2BH5mYGheSZOqQm2PS2gfKrc%2BDIFtyX3RFtpBOEwSX78fuWwYgAf1uaevROkA7R17BGsCRwcyLMr1BmNLUzZvasBT8GdOwlHH15ErrCvDEyPiWb8HSGFPpmiqKk%2Bko3%2Ba67g8YZRGZImvnj8aHTeZLlZN%2FxBqQAh3eEIAaNAkSqyw1GIR1SpapgA%3D;
43
+ path=/natural-language-understanding/api; secure; HttpOnly
44
+ X-Client-Ip:
45
+ - 50.67.27.28
46
+ X-Global-Transaction-Id:
47
+ - '725228624'
48
+ Strict-Transport-Security:
49
+ - max-age=31536000;
50
+ X-Dp-Watson-Tran-Id:
51
+ - gateway-dp01-725228624
52
+ body:
53
+ encoding: UTF-8
54
+ string: |-
55
+ {
56
+ "language": "en",
57
+ "keywords": [
58
+ {
59
+ "text": "Kieran",
60
+ "relevance": 0.970239
61
+ }
62
+ ]
63
+ }
64
+ http_version:
65
+ recorded_at: Thu, 13 Apr 2017 19:45:29 GMT
66
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm-watson-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bram Whillock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -136,12 +150,55 @@ dependencies:
136
150
  - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: dotenv
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
139
195
  description: "."
140
196
  email: bramski@gmail.com
141
197
  executables: []
142
198
  extensions: []
143
199
  extra_rdoc_files: []
144
200
  files:
201
+ - ".env.example"
145
202
  - ".gitignore"
146
203
  - Gemfile
147
204
  - README.md
@@ -153,14 +210,20 @@ files:
153
210
  - lib/ibm_watson/conversation.rb
154
211
  - lib/ibm_watson/conversation/dialog_node.rb
155
212
  - lib/ibm_watson/conversation/intent.rb
156
- - lib/ibm_watson/conversation/intent_result.rb
157
- - lib/ibm_watson/conversation/result.rb
213
+ - lib/ibm_watson/conversation/message_response.rb
214
+ - lib/ibm_watson/conversation/runtime_entity.rb
215
+ - lib/ibm_watson/conversation/runtime_intent.rb
158
216
  - lib/ibm_watson/conversation/service.rb
159
217
  - lib/ibm_watson/conversation/workspace.rb
160
218
  - lib/ibm_watson/errors.rb
219
+ - lib/ibm_watson/nlu.rb
220
+ - lib/ibm_watson/nlu/analyze_result.rb
221
+ - lib/ibm_watson/nlu/service.rb
161
222
  - lib/ibm_watson/version.rb
223
+ - lib/ibm_watson_ruby.rb
162
224
  - spec/assets/poc_workspace.json
163
225
  - spec/ibm_watson/conversation/service_spec.rb
226
+ - spec/ibm_watson/nlu/service_spec.rb
164
227
  - spec/spec_helper.rb
165
228
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_create_workspace_.yml
166
229
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_delete_workspace_.yml
@@ -168,6 +231,7 @@ files:
168
231
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_message_.yml
169
232
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_update_workspace_.yml
170
233
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_workspace_.yml
234
+ - spec/vcr_cassettes/ibm_watson/nlu/service/ibm_watson_nlu_service_keyword_extraction_.yml
171
235
  homepage: https://github.com/imrealtor/watson-ruby
172
236
  licenses:
173
237
  - MIT
@@ -195,6 +259,7 @@ summary: IBM Watson services in ruby
195
259
  test_files:
196
260
  - spec/assets/poc_workspace.json
197
261
  - spec/ibm_watson/conversation/service_spec.rb
262
+ - spec/ibm_watson/nlu/service_spec.rb
198
263
  - spec/spec_helper.rb
199
264
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_create_workspace_.yml
200
265
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_delete_workspace_.yml
@@ -202,3 +267,4 @@ test_files:
202
267
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_message_.yml
203
268
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_update_workspace_.yml
204
269
  - spec/vcr_cassettes/ibm_watson/conversation/service/ibm_watson_conversation_service_workspace_.yml
270
+ - spec/vcr_cassettes/ibm_watson/nlu/service/ibm_watson_nlu_service_keyword_extraction_.yml
@@ -1,24 +0,0 @@
1
- module IBMWatson
2
- module Conversation
3
- class Result < IBMWatson::BaseModel
4
- attribute :entities
5
- attribute :input
6
- attribute :output
7
- attribute :context
8
- attribute :alternate_intents
9
-
10
- def intents=(values)
11
- @intents = values.map do |value|
12
- ::IBMWatson::Conversation::IntentResult.new(value)
13
- end
14
- end
15
- attr_reader :intents
16
-
17
- def as_json(*)
18
- super.merge({
19
- "intents" => intents.as_json
20
- })
21
- end
22
- end
23
- end
24
- end