ibm_watson 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ibm_watson/assistant_v1.rb +791 -736
- data/lib/ibm_watson/assistant_v2.rb +12 -8
- data/lib/ibm_watson/common.rb +2 -1
- data/lib/ibm_watson/compare_comply_v1.rb +171 -169
- data/lib/ibm_watson/discovery_v1.rb +778 -689
- data/lib/ibm_watson/language_translator_v3.rb +65 -63
- data/lib/ibm_watson/natural_language_classifier_v1.rb +36 -35
- data/lib/ibm_watson/natural_language_understanding_v1.rb +28 -25
- data/lib/ibm_watson/personality_insights_v3.rb +10 -10
- data/lib/ibm_watson/speech_to_text_v1.rb +764 -702
- data/lib/ibm_watson/text_to_speech_v1.rb +215 -200
- data/lib/ibm_watson/tone_analyzer_v3.rb +10 -9
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +94 -95
- data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +1 -1
- data/test/integration/test_assistant_v1.rb +18 -289
- data/test/integration/test_assistant_v2.rb +21 -31
- data/test/integration/test_discovery_v1.rb +21 -18
- data/test/integration/test_language_translator_v3.rb +3 -3
- data/test/integration/test_natural_language_classifier_v1.rb +3 -3
- data/test/integration/test_natural_language_understanding_v1.rb +16 -20
- data/test/integration/test_personality_insights_v3.rb +12 -40
- data/test/integration/test_speech_to_text_v1.rb +3 -3
- data/test/integration/test_text_to_speech_v1.rb +3 -3
- data/test/integration/test_tone_analyzer_v3.rb +14 -31
- data/test/integration/test_visual_recognition_v3.rb +3 -3
- data/test/unit/test_compare_comply_v1.rb +3 -7
- data/test/unit/test_discovery_v1.rb +21 -7
- data/test/unit/test_language_translator_v3.rb +1 -3
- data/test/unit/test_natural_language_classifier_v1.rb +1 -3
- data/test/unit/test_speech_to_text_v1.rb +25 -7
- data/test/unit/test_text_to_speech_v1.rb +0 -4
- data/test/unit/test_visual_recognition_v3.rb +2 -6
- metadata +2 -2
@@ -21,7 +21,6 @@
|
|
21
21
|
require "concurrent"
|
22
22
|
require "erb"
|
23
23
|
require "json"
|
24
|
-
|
25
24
|
require "ibm_cloud_sdk_core"
|
26
25
|
require_relative "./common.rb"
|
27
26
|
|
@@ -97,7 +96,7 @@ module IBMWatson
|
|
97
96
|
# @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
|
98
97
|
# on the **Assistants** tab of the Watson Assistant tool. For information about
|
99
98
|
# creating assistants, see the
|
100
|
-
# [documentation](https://console.bluemix.net/docs/services/assistant/
|
99
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
|
101
100
|
#
|
102
101
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
103
102
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
@@ -106,7 +105,8 @@ module IBMWatson
|
|
106
105
|
|
107
106
|
headers = {
|
108
107
|
}
|
109
|
-
|
108
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "create_session")
|
109
|
+
headers.merge!(sdk_headers)
|
110
110
|
|
111
111
|
params = {
|
112
112
|
"version" => @version
|
@@ -131,7 +131,7 @@ module IBMWatson
|
|
131
131
|
# @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
|
132
132
|
# on the **Assistants** tab of the Watson Assistant tool. For information about
|
133
133
|
# creating assistants, see the
|
134
|
-
# [documentation](https://console.bluemix.net/docs/services/assistant/
|
134
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
|
135
135
|
#
|
136
136
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
137
137
|
# @param session_id [String] Unique identifier of the session.
|
@@ -143,7 +143,8 @@ module IBMWatson
|
|
143
143
|
|
144
144
|
headers = {
|
145
145
|
}
|
146
|
-
|
146
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "delete_session")
|
147
|
+
headers.merge!(sdk_headers)
|
147
148
|
|
148
149
|
params = {
|
149
150
|
"version" => @version
|
@@ -173,12 +174,14 @@ module IBMWatson
|
|
173
174
|
# @param assistant_id [String] Unique identifier of the assistant. You can find the assistant ID of an assistant
|
174
175
|
# on the **Assistants** tab of the Watson Assistant tool. For information about
|
175
176
|
# creating assistants, see the
|
176
|
-
# [documentation](https://console.bluemix.net/docs/services/assistant/
|
177
|
+
# [documentation](https://console.bluemix.net/docs/services/assistant/assistant-add.html#assistant-add-task).
|
177
178
|
#
|
178
179
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
179
180
|
# @param session_id [String] Unique identifier of the session.
|
180
181
|
# @param input [MessageInput] An input object that includes the input text.
|
181
|
-
# @param context [MessageContext] State information for the conversation.
|
182
|
+
# @param context [MessageContext] State information for the conversation. The context is stored by the assistant on
|
183
|
+
# a per-session basis. You can use this property to set or modify context variables,
|
184
|
+
# which can also be accessed by dialog nodes.
|
182
185
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
183
186
|
def message(assistant_id:, session_id:, input: nil, context: nil)
|
184
187
|
raise ArgumentError.new("assistant_id must be provided") if assistant_id.nil?
|
@@ -187,7 +190,8 @@ module IBMWatson
|
|
187
190
|
|
188
191
|
headers = {
|
189
192
|
}
|
190
|
-
|
193
|
+
sdk_headers = Common.new.get_sdk_headers("conversation", "V2", "message")
|
194
|
+
headers.merge!(sdk_headers)
|
191
195
|
|
192
196
|
params = {
|
193
197
|
"version" => @version
|
data/lib/ibm_watson/common.rb
CHANGED
@@ -5,7 +5,8 @@ module IBMWatson
|
|
5
5
|
class Common
|
6
6
|
def initialize(*); end
|
7
7
|
|
8
|
-
def get_sdk_headers(
|
8
|
+
def get_sdk_headers(service_name, service_version, operation_id)
|
9
|
+
headers = {}
|
9
10
|
user_agent_string = "watson-apis-ruby-sdk-" + IBMWatson::VERSION + " #{RbConfig::CONFIG["host"]}"
|
10
11
|
user_agent_string += " #{RbConfig::CONFIG["RUBY_BASE_NAME"]}-#{RbConfig::CONFIG["RUBY_PROGRAM_VERSION"]}"
|
11
12
|
|
@@ -20,7 +20,6 @@
|
|
20
20
|
require "concurrent"
|
21
21
|
require "erb"
|
22
22
|
require "json"
|
23
|
-
|
24
23
|
require "ibm_cloud_sdk_core"
|
25
24
|
require_relative "./common.rb"
|
26
25
|
|
@@ -77,27 +76,28 @@ module IBMWatson
|
|
77
76
|
#########################
|
78
77
|
|
79
78
|
##
|
80
|
-
# @!method convert_to_html(file:,
|
81
|
-
# Convert
|
82
|
-
#
|
83
|
-
# @param file [File] The
|
84
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
85
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
86
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
87
|
-
# well as to the methods' use in batch-processing requests.
|
88
|
-
# @param file_content_type [String] The content type of file.
|
79
|
+
# @!method convert_to_html(file:, filename: nil, file_content_type: nil, model: nil)
|
80
|
+
# Convert document to HTML.
|
81
|
+
# Converts a document to HTML.
|
82
|
+
# @param file [File] The document to convert.
|
89
83
|
# @param filename [String] The filename for file.
|
84
|
+
# @param file_content_type [String] The content type of file.
|
85
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
86
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
87
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
88
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
90
89
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
91
|
-
def convert_to_html(file:,
|
90
|
+
def convert_to_html(file:, filename: nil, file_content_type: nil, model: nil)
|
92
91
|
raise ArgumentError.new("file must be provided") if file.nil?
|
93
92
|
|
94
93
|
headers = {
|
95
94
|
}
|
96
|
-
|
95
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "convert_to_html")
|
96
|
+
headers.merge!(sdk_headers)
|
97
97
|
|
98
98
|
params = {
|
99
99
|
"version" => @version,
|
100
|
-
"
|
100
|
+
"model" => model
|
101
101
|
}
|
102
102
|
|
103
103
|
form_data = {}
|
@@ -125,27 +125,27 @@ module IBMWatson
|
|
125
125
|
#########################
|
126
126
|
|
127
127
|
##
|
128
|
-
# @!method classify_elements(file:,
|
128
|
+
# @!method classify_elements(file:, file_content_type: nil, model: nil)
|
129
129
|
# Classify the elements of a document.
|
130
|
-
#
|
131
|
-
# @param file [File] The
|
132
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
133
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
134
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
135
|
-
# well as to the methods' use in batch-processing requests.
|
130
|
+
# Analyzes the structural and semantic elements of a document.
|
131
|
+
# @param file [File] The document to classify.
|
136
132
|
# @param file_content_type [String] The content type of file.
|
137
|
-
# @param
|
133
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
134
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
135
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
136
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
138
137
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
139
|
-
def classify_elements(file:,
|
138
|
+
def classify_elements(file:, file_content_type: nil, model: nil)
|
140
139
|
raise ArgumentError.new("file must be provided") if file.nil?
|
141
140
|
|
142
141
|
headers = {
|
143
142
|
}
|
144
|
-
|
143
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "classify_elements")
|
144
|
+
headers.merge!(sdk_headers)
|
145
145
|
|
146
146
|
params = {
|
147
147
|
"version" => @version,
|
148
|
-
"
|
148
|
+
"model" => model
|
149
149
|
}
|
150
150
|
|
151
151
|
form_data = {}
|
@@ -153,8 +153,7 @@ module IBMWatson
|
|
153
153
|
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
154
154
|
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
155
155
|
end
|
156
|
-
|
157
|
-
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
|
156
|
+
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: file.respond_to?(:path) ? file.path : nil)
|
158
157
|
|
159
158
|
method_url = "/v1/element_classification"
|
160
159
|
|
@@ -173,27 +172,27 @@ module IBMWatson
|
|
173
172
|
#########################
|
174
173
|
|
175
174
|
##
|
176
|
-
# @!method extract_tables(file:,
|
175
|
+
# @!method extract_tables(file:, file_content_type: nil, model: nil)
|
177
176
|
# Extract a document's tables.
|
178
|
-
#
|
179
|
-
# @param file [File] The
|
180
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
181
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
182
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
183
|
-
# well as to the methods' use in batch-processing requests.
|
177
|
+
# Analyzes the tables in a document.
|
178
|
+
# @param file [File] The document on which to run table extraction.
|
184
179
|
# @param file_content_type [String] The content type of file.
|
185
|
-
# @param
|
180
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
181
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
182
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
183
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
186
184
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
187
|
-
def extract_tables(file:,
|
185
|
+
def extract_tables(file:, file_content_type: nil, model: nil)
|
188
186
|
raise ArgumentError.new("file must be provided") if file.nil?
|
189
187
|
|
190
188
|
headers = {
|
191
189
|
}
|
192
|
-
|
190
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "extract_tables")
|
191
|
+
headers.merge!(sdk_headers)
|
193
192
|
|
194
193
|
params = {
|
195
194
|
"version" => @version,
|
196
|
-
"
|
195
|
+
"model" => model
|
197
196
|
}
|
198
197
|
|
199
198
|
form_data = {}
|
@@ -201,8 +200,7 @@ module IBMWatson
|
|
201
200
|
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
202
201
|
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
203
202
|
end
|
204
|
-
|
205
|
-
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
|
203
|
+
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: file.respond_to?(:path) ? file.path : nil)
|
206
204
|
|
207
205
|
method_url = "/v1/tables"
|
208
206
|
|
@@ -221,36 +219,35 @@ module IBMWatson
|
|
221
219
|
#########################
|
222
220
|
|
223
221
|
##
|
224
|
-
# @!method compare_documents(file_1:, file_2:,
|
222
|
+
# @!method compare_documents(file_1:, file_2:, file_1_content_type: nil, file_2_content_type: nil, file_1_label: nil, file_2_label: nil, model: nil)
|
225
223
|
# Compare two documents.
|
226
|
-
#
|
227
|
-
# @param file_1 [File] The first
|
228
|
-
# @param file_2 [File] The second
|
229
|
-
# @param file_1_label [String] A text label for the first file.
|
230
|
-
# @param file_2_label [String] A text label for the second file.
|
231
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
232
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
233
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
234
|
-
# well as to the methods' use in batch-processing requests.
|
224
|
+
# Compares two input documents. Documents must be in the same format.
|
225
|
+
# @param file_1 [File] The first document to compare.
|
226
|
+
# @param file_2 [File] The second document to compare.
|
235
227
|
# @param file_1_content_type [String] The content type of file_1.
|
236
|
-
# @param file_1_filename [String] The filename for file_1.
|
237
228
|
# @param file_2_content_type [String] The content type of file_2.
|
238
|
-
# @param
|
229
|
+
# @param file_1_label [String] A text label for the first document.
|
230
|
+
# @param file_2_label [String] A text label for the second document.
|
231
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
232
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
233
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
234
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
239
235
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
240
|
-
def compare_documents(file_1:, file_2:,
|
236
|
+
def compare_documents(file_1:, file_2:, file_1_content_type: nil, file_2_content_type: nil, file_1_label: nil, file_2_label: nil, model: nil)
|
241
237
|
raise ArgumentError.new("file_1 must be provided") if file_1.nil?
|
242
238
|
|
243
239
|
raise ArgumentError.new("file_2 must be provided") if file_2.nil?
|
244
240
|
|
245
241
|
headers = {
|
246
242
|
}
|
247
|
-
|
243
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "compare_documents")
|
244
|
+
headers.merge!(sdk_headers)
|
248
245
|
|
249
246
|
params = {
|
250
247
|
"version" => @version,
|
251
248
|
"file_1_label" => file_1_label,
|
252
249
|
"file_2_label" => file_2_label,
|
253
|
-
"
|
250
|
+
"model" => model
|
254
251
|
}
|
255
252
|
|
256
253
|
form_data = {}
|
@@ -258,14 +255,12 @@ module IBMWatson
|
|
258
255
|
unless file_1.instance_of?(StringIO) || file_1.instance_of?(File)
|
259
256
|
file_1 = file_1.respond_to?(:to_json) ? StringIO.new(file_1.to_json) : StringIO.new(file_1)
|
260
257
|
end
|
261
|
-
|
262
|
-
form_data[:file_1] = HTTP::FormData::File.new(file_1, content_type: file_1_content_type.nil? ? "application/octet-stream" : file_1_content_type, filename: file_1_filename)
|
258
|
+
form_data[:file_1] = HTTP::FormData::File.new(file_1, content_type: file_1_content_type.nil? ? "application/octet-stream" : file_1_content_type, filename: file_1.respond_to?(:path) ? file_1.path : nil)
|
263
259
|
|
264
260
|
unless file_2.instance_of?(StringIO) || file_2.instance_of?(File)
|
265
261
|
file_2 = file_2.respond_to?(:to_json) ? StringIO.new(file_2.to_json) : StringIO.new(file_2)
|
266
262
|
end
|
267
|
-
|
268
|
-
form_data[:file_2] = HTTP::FormData::File.new(file_2, content_type: file_2_content_type.nil? ? "application/octet-stream" : file_2_content_type, filename: file_2_filename)
|
263
|
+
form_data[:file_2] = HTTP::FormData::File.new(file_2, content_type: file_2_content_type.nil? ? "application/octet-stream" : file_2_content_type, filename: file_2.respond_to?(:path) ? file_2.path : nil)
|
269
264
|
|
270
265
|
method_url = "/v1/comparison"
|
271
266
|
|
@@ -300,7 +295,8 @@ module IBMWatson
|
|
300
295
|
|
301
296
|
headers = {
|
302
297
|
}
|
303
|
-
|
298
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "add_feedback")
|
299
|
+
headers.merge!(sdk_headers)
|
304
300
|
|
305
301
|
params = {
|
306
302
|
"version" => @version
|
@@ -325,9 +321,80 @@ module IBMWatson
|
|
325
321
|
response
|
326
322
|
end
|
327
323
|
|
324
|
+
##
|
325
|
+
# @!method delete_feedback(feedback_id:, model: nil)
|
326
|
+
# Delete a specified feedback entry.
|
327
|
+
# Deletes a feedback entry with a specified `feedback_id`.
|
328
|
+
# @param feedback_id [String] A string that specifies the feedback entry to be deleted from the document.
|
329
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
330
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
331
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
332
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
333
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
334
|
+
def delete_feedback(feedback_id:, model: nil)
|
335
|
+
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
336
|
+
|
337
|
+
headers = {
|
338
|
+
}
|
339
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "delete_feedback")
|
340
|
+
headers.merge!(sdk_headers)
|
341
|
+
|
342
|
+
params = {
|
343
|
+
"version" => @version,
|
344
|
+
"model" => model
|
345
|
+
}
|
346
|
+
|
347
|
+
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
348
|
+
|
349
|
+
response = request(
|
350
|
+
method: "DELETE",
|
351
|
+
url: method_url,
|
352
|
+
headers: headers,
|
353
|
+
params: params,
|
354
|
+
accept_json: true
|
355
|
+
)
|
356
|
+
response
|
357
|
+
end
|
358
|
+
|
359
|
+
##
|
360
|
+
# @!method get_feedback(feedback_id:, model: nil)
|
361
|
+
# List a specified feedback entry.
|
362
|
+
# Lists a feedback entry with a specified `feedback_id`.
|
363
|
+
# @param feedback_id [String] A string that specifies the feedback entry to be included in the output.
|
364
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
365
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
366
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
367
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
368
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
369
|
+
def get_feedback(feedback_id:, model: nil)
|
370
|
+
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
371
|
+
|
372
|
+
headers = {
|
373
|
+
}
|
374
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_feedback")
|
375
|
+
headers.merge!(sdk_headers)
|
376
|
+
|
377
|
+
params = {
|
378
|
+
"version" => @version,
|
379
|
+
"model" => model
|
380
|
+
}
|
381
|
+
|
382
|
+
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
383
|
+
|
384
|
+
response = request(
|
385
|
+
method: "GET",
|
386
|
+
url: method_url,
|
387
|
+
headers: headers,
|
388
|
+
params: params,
|
389
|
+
accept_json: true
|
390
|
+
)
|
391
|
+
response
|
392
|
+
end
|
393
|
+
|
328
394
|
##
|
329
395
|
# @!method list_feedback(feedback_type: nil, before: nil, after: nil, document_title: nil, model_id: nil, model_version: nil, category_removed: nil, category_added: nil, category_not_changed: nil, type_removed: nil, type_added: nil, type_not_changed: nil, page_limit: nil, cursor: nil, sort: nil, include_total: nil)
|
330
|
-
# List the feedback in
|
396
|
+
# List the feedback in a document.
|
397
|
+
# Lists the feedback in a document.
|
331
398
|
# @param feedback_type [String] An optional string that filters the output to include only feedback with the
|
332
399
|
# specified feedback type. The only permitted value is `element_classification`.
|
333
400
|
# @param before [Time] An optional string in the format `YYYY-MM-DD` that filters the output to include
|
@@ -373,7 +440,8 @@ module IBMWatson
|
|
373
440
|
def list_feedback(feedback_type: nil, before: nil, after: nil, document_title: nil, model_id: nil, model_version: nil, category_removed: nil, category_added: nil, category_not_changed: nil, type_removed: nil, type_added: nil, type_not_changed: nil, page_limit: nil, cursor: nil, sort: nil, include_total: nil)
|
374
441
|
headers = {
|
375
442
|
}
|
376
|
-
|
443
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "list_feedback")
|
444
|
+
headers.merge!(sdk_headers)
|
377
445
|
|
378
446
|
params = {
|
379
447
|
"version" => @version,
|
@@ -406,78 +474,12 @@ module IBMWatson
|
|
406
474
|
)
|
407
475
|
response
|
408
476
|
end
|
409
|
-
|
410
|
-
##
|
411
|
-
# @!method get_feedback(feedback_id:, model_id: nil)
|
412
|
-
# List a specified feedback entry.
|
413
|
-
# @param feedback_id [String] A string that specifies the feedback entry to be included in the output.
|
414
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
415
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
416
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
417
|
-
# well as to the methods' use in batch-processing requests.
|
418
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
419
|
-
def get_feedback(feedback_id:, model_id: nil)
|
420
|
-
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
421
|
-
|
422
|
-
headers = {
|
423
|
-
}
|
424
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "compare-comply", service_version: "V1", operation_id: "get_feedback")
|
425
|
-
|
426
|
-
params = {
|
427
|
-
"version" => @version,
|
428
|
-
"model_id" => model_id
|
429
|
-
}
|
430
|
-
|
431
|
-
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
432
|
-
|
433
|
-
response = request(
|
434
|
-
method: "GET",
|
435
|
-
url: method_url,
|
436
|
-
headers: headers,
|
437
|
-
params: params,
|
438
|
-
accept_json: true
|
439
|
-
)
|
440
|
-
response
|
441
|
-
end
|
442
|
-
|
443
|
-
##
|
444
|
-
# @!method delete_feedback(feedback_id:, model_id: nil)
|
445
|
-
# Deletes a specified feedback entry.
|
446
|
-
# @param feedback_id [String] A string that specifies the feedback entry to be deleted from the document.
|
447
|
-
# @param model_id [String] The analysis model to be used by the service. For the `/v1/element_classification`
|
448
|
-
# and `/v1/comparison` methods, the default is `contracts`. For the `/v1/tables`
|
449
|
-
# method, the default is `tables`. These defaults apply to the standalone methods as
|
450
|
-
# well as to the methods' use in batch-processing requests.
|
451
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
452
|
-
def delete_feedback(feedback_id:, model_id: nil)
|
453
|
-
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
454
|
-
|
455
|
-
headers = {
|
456
|
-
}
|
457
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "compare-comply", service_version: "V1", operation_id: "delete_feedback")
|
458
|
-
|
459
|
-
params = {
|
460
|
-
"version" => @version,
|
461
|
-
"model_id" => model_id
|
462
|
-
}
|
463
|
-
|
464
|
-
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
465
|
-
|
466
|
-
response = request(
|
467
|
-
method: "DELETE",
|
468
|
-
url: method_url,
|
469
|
-
headers: headers,
|
470
|
-
params: params,
|
471
|
-
accept_json: true
|
472
|
-
)
|
473
|
-
response
|
474
|
-
end
|
475
477
|
#########################
|
476
478
|
# Batches
|
477
479
|
#########################
|
478
480
|
|
479
481
|
##
|
480
|
-
# @!method create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:,
|
482
|
+
# @!method create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:, model: nil)
|
481
483
|
# Submit a batch-processing request.
|
482
484
|
# Run Compare and Comply methods over a collection of input documents.
|
483
485
|
# **Important:** Batch processing requires the use of the [IBM Cloud Object Storage
|
@@ -500,14 +502,12 @@ module IBMWatson
|
|
500
502
|
# the **Endpoint** tab of your Cloud Object Storage instance; for example, `us-geo`,
|
501
503
|
# `eu-geo`, or `ap-geo`.
|
502
504
|
# @param output_bucket_name [String] The name of the Cloud Object Storage output bucket.
|
503
|
-
# @param
|
504
|
-
# and
|
505
|
-
# method, the default is `tables`. These defaults apply to the
|
506
|
-
# well as to the methods' use in batch-processing requests.
|
507
|
-
# @param input_credentials_filename [String] The filename for input_credentials_file.
|
508
|
-
# @param output_credentials_filename [String] The filename for output_credentials_file.
|
505
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
506
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
507
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
508
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
509
509
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
510
|
-
def create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:,
|
510
|
+
def create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:, model: nil)
|
511
511
|
raise ArgumentError.new("function must be provided") if function.nil?
|
512
512
|
|
513
513
|
raise ArgumentError.new("input_credentials_file must be provided") if input_credentials_file.nil?
|
@@ -524,12 +524,13 @@ module IBMWatson
|
|
524
524
|
|
525
525
|
headers = {
|
526
526
|
}
|
527
|
-
|
527
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "create_batch")
|
528
|
+
headers.merge!(sdk_headers)
|
528
529
|
|
529
530
|
params = {
|
530
531
|
"version" => @version,
|
531
532
|
"function" => function,
|
532
|
-
"
|
533
|
+
"model" => model
|
533
534
|
}
|
534
535
|
|
535
536
|
form_data = {}
|
@@ -537,8 +538,7 @@ module IBMWatson
|
|
537
538
|
unless input_credentials_file.instance_of?(StringIO) || input_credentials_file.instance_of?(File)
|
538
539
|
input_credentials_file = input_credentials_file.respond_to?(:to_json) ? StringIO.new(input_credentials_file.to_json) : StringIO.new(input_credentials_file)
|
539
540
|
end
|
540
|
-
|
541
|
-
form_data[:input_credentials_file] = HTTP::FormData::File.new(input_credentials_file, content_type: "application/json", filename: input_credentials_filename)
|
541
|
+
form_data[:input_credentials_file] = HTTP::FormData::File.new(input_credentials_file, content_type: "application/json", filename: input_credentials_file.respond_to?(:path) ? input_credentials_file.path : nil)
|
542
542
|
|
543
543
|
form_data[:input_bucket_location] = HTTP::FormData::Part.new(input_bucket_location.to_s, content_type: "text/plain")
|
544
544
|
|
@@ -547,8 +547,7 @@ module IBMWatson
|
|
547
547
|
unless output_credentials_file.instance_of?(StringIO) || output_credentials_file.instance_of?(File)
|
548
548
|
output_credentials_file = output_credentials_file.respond_to?(:to_json) ? StringIO.new(output_credentials_file.to_json) : StringIO.new(output_credentials_file)
|
549
549
|
end
|
550
|
-
|
551
|
-
form_data[:output_credentials_file] = HTTP::FormData::File.new(output_credentials_file, content_type: "application/json", filename: output_credentials_filename)
|
550
|
+
form_data[:output_credentials_file] = HTTP::FormData::File.new(output_credentials_file, content_type: "application/json", filename: output_credentials_file.respond_to?(:path) ? output_credentials_file.path : nil)
|
552
551
|
|
553
552
|
form_data[:output_bucket_location] = HTTP::FormData::Part.new(output_bucket_location.to_s, content_type: "text/plain")
|
554
553
|
|
@@ -568,20 +567,24 @@ module IBMWatson
|
|
568
567
|
end
|
569
568
|
|
570
569
|
##
|
571
|
-
# @!method
|
572
|
-
#
|
573
|
-
#
|
570
|
+
# @!method get_batch(batch_id:)
|
571
|
+
# Get information about a specific batch-processing job.
|
572
|
+
# Gets information about a batch-processing job with a specified ID.
|
573
|
+
# @param batch_id [String] The ID of the batch-processing job whose information you want to retrieve.
|
574
574
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
575
|
-
def
|
575
|
+
def get_batch(batch_id:)
|
576
|
+
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
577
|
+
|
576
578
|
headers = {
|
577
579
|
}
|
578
|
-
|
580
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_batch")
|
581
|
+
headers.merge!(sdk_headers)
|
579
582
|
|
580
583
|
params = {
|
581
584
|
"version" => @version
|
582
585
|
}
|
583
586
|
|
584
|
-
method_url = "/v1/batches"
|
587
|
+
method_url = "/v1/batches/%s" % [ERB::Util.url_encode(batch_id)]
|
585
588
|
|
586
589
|
response = request(
|
587
590
|
method: "GET",
|
@@ -594,23 +597,21 @@ module IBMWatson
|
|
594
597
|
end
|
595
598
|
|
596
599
|
##
|
597
|
-
# @!method
|
598
|
-
#
|
599
|
-
#
|
600
|
-
# @param batch_id [String] The ID of the batch-processing request whose information you want to retrieve.
|
600
|
+
# @!method list_batches
|
601
|
+
# List submitted batch-processing jobs.
|
602
|
+
# Lists batch-processing jobs submitted by users.
|
601
603
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
602
|
-
def
|
603
|
-
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
604
|
-
|
604
|
+
def list_batches
|
605
605
|
headers = {
|
606
606
|
}
|
607
|
-
|
607
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "list_batches")
|
608
|
+
headers.merge!(sdk_headers)
|
608
609
|
|
609
610
|
params = {
|
610
611
|
"version" => @version
|
611
612
|
}
|
612
613
|
|
613
|
-
method_url = "/v1/batches
|
614
|
+
method_url = "/v1/batches"
|
614
615
|
|
615
616
|
response = request(
|
616
617
|
method: "GET",
|
@@ -623,30 +624,31 @@ module IBMWatson
|
|
623
624
|
end
|
624
625
|
|
625
626
|
##
|
626
|
-
# @!method update_batch(batch_id:, action:,
|
627
|
-
# Update a pending or active batch-processing
|
628
|
-
#
|
629
|
-
#
|
630
|
-
# @param batch_id [String] The ID of the batch-processing
|
631
|
-
# @param action [String] The action you want to perform on the specified batch-processing
|
632
|
-
# @param
|
633
|
-
# and
|
634
|
-
# method, the default is `tables`. These defaults apply to the
|
635
|
-
# well as to the methods' use in batch-processing requests.
|
627
|
+
# @!method update_batch(batch_id:, action:, model: nil)
|
628
|
+
# Update a pending or active batch-processing job.
|
629
|
+
# Updates a pending or active batch-processing job. You can rescan the input bucket
|
630
|
+
# to check for new documents or cancel a job.
|
631
|
+
# @param batch_id [String] The ID of the batch-processing job you want to update.
|
632
|
+
# @param action [String] The action you want to perform on the specified batch-processing job.
|
633
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
634
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
635
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
636
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
636
637
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
637
|
-
def update_batch(batch_id:, action:,
|
638
|
+
def update_batch(batch_id:, action:, model: nil)
|
638
639
|
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
639
640
|
|
640
641
|
raise ArgumentError.new("action must be provided") if action.nil?
|
641
642
|
|
642
643
|
headers = {
|
643
644
|
}
|
644
|
-
|
645
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "update_batch")
|
646
|
+
headers.merge!(sdk_headers)
|
645
647
|
|
646
648
|
params = {
|
647
649
|
"version" => @version,
|
648
650
|
"action" => action,
|
649
|
-
"
|
651
|
+
"model" => model
|
650
652
|
}
|
651
653
|
|
652
654
|
method_url = "/v1/batches/%s" % [ERB::Util.url_encode(batch_id)]
|