watson-api-client 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/examples/NaturalLanguageClassifier/README.md +1 -1
- data/lib/watson-api-client.rb +18 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a2646b96efeeb11df4449d50e90b608e9c46e2f
|
4
|
+
data.tar.gz: 2e9dde8b4e9fec5e4b5e93d3fa1834563e175c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11a31a33261b5c0855ac05212251dcb7ed8727666ce409b4291e4fa456ef79f6518a8997b709f9991c6d5d0a5cdc24915b2ce6a7d9c31392dc5d05c1243602a4
|
7
|
+
data.tar.gz: 96e78f15eb243612f0b618ef097aa232718f10e86f81a1749918641ff8ff3a51e21d0660928c5004bc2d1aebbf4864ef6bb5392f3e63634cb7eeb9e0f4eb2aeb
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
================================================================
|
3
3
|
|
4
4
|
[](http://badge.fury.io/rb/watson-api-client)
|
5
|
-
[](https://travis-ci.org/blueboxjesse/watson-api-client)
|
6
5
|
|
7
6
|
The [watson-api-client](http://rubygems.org/gems/watson-api-client) is a gem to use REST API on the IBM Watson™ Developer Cloud.
|
8
7
|
|
@@ -13,7 +13,7 @@ Otherwise, you should specify :user and :password parameters for each WatsonAPIC
|
|
13
13
|
|
14
14
|
###Example dataset
|
15
15
|
|
16
|
-
Download the example dataset archive from [here](
|
16
|
+
Download the example dataset archive from [here](https://www.dropbox.com/sh/h2u6irutgbgvm9r/AAA9GsagC2vYlWPgOIEj-kHZa?dl=0) and extract it to examples/NaturalLanguageClassifier/blog_text/.
|
17
17
|
|
18
18
|
|
19
19
|
2.Training
|
data/lib/watson-api-client.rb
CHANGED
@@ -6,7 +6,7 @@ require 'pp' if __FILE__ == $PROGRAM_NAME
|
|
6
6
|
|
7
7
|
class WatsonAPIClient
|
8
8
|
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.8'
|
10
10
|
|
11
11
|
class Alchemy < self; end
|
12
12
|
|
@@ -45,9 +45,15 @@ class WatsonAPIClient
|
|
45
45
|
methods = Hash.new {|h,k| h[k] = {}}
|
46
46
|
digest = Hash.new {|h,k| h[k] = {}}
|
47
47
|
apis['paths'].each_pair do |path, operations|
|
48
|
+
common_parameters = nil
|
48
49
|
operations.each_pair do |access, operation|
|
50
|
+
if access == 'parameters'
|
51
|
+
common_parameters = operation
|
52
|
+
next
|
53
|
+
end
|
49
54
|
body, query, min, max = nil, [], [], []
|
50
55
|
if operation['parameters']
|
56
|
+
operation['parameters'] += common_parameters if common_parameters
|
51
57
|
(0...operation['parameters'].size).to_a.reverse.each do |index|
|
52
58
|
parameter = operation['parameters'][index]
|
53
59
|
operation['parameters'][index..index] = apis['parameters'][parameter[parameter.keys.first].split('/').last] if parameter.keys.first == '$ref'
|
@@ -76,7 +82,7 @@ class WatsonAPIClient
|
|
76
82
|
:gateway => 'https://gateway.watsonplatform.net',
|
77
83
|
:gateway_a => 'https://gateway-a.watsonplatform.net',
|
78
84
|
:doc_base1 => 'https://watson-api-explorer.mybluemix.net/',
|
79
|
-
:doc_base2 => '
|
85
|
+
:doc_base2 => 'https://www.ibm.com/watson/developercloud/doc/',
|
80
86
|
:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE
|
81
87
|
}
|
82
88
|
JSON.parse(ENV['WATSON_API_DOCS'] || '{}').each_pair do |key, value|
|
@@ -153,9 +159,16 @@ class WatsonAPIClient
|
|
153
159
|
def define_api_methods
|
154
160
|
self.class::API['methods'].each_pair do |method, definition|
|
155
161
|
self.class.module_eval %Q{define_method("#{method}",
|
156
|
-
Proc.new {|options={}|
|
157
|
-
|
158
|
-
|
162
|
+
Proc.new {|options={}|
|
163
|
+
begin
|
164
|
+
rest_access_#{definition.keys.size > 1 ? 'auto_detect' :
|
165
|
+
definition[definition.keys.first]['body'] ? 'with_body' :
|
166
|
+
'without_body' }("#{method}", options.dup)
|
167
|
+
rescue RestClient::ExceptionWithResponse => error
|
168
|
+
STDERR.puts ["Failed method: #{self.class}##{method}", options]
|
169
|
+
raise error
|
170
|
+
end
|
171
|
+
}
|
159
172
|
)} unless respond_to?(method)
|
160
173
|
end
|
161
174
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watson-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi SUGA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|