ibm_watson 2.0.2 → 2.1.3
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 +6 -29
- data/lib/ibm_watson/assistant_v1.rb +114 -79
- data/lib/ibm_watson/assistant_v2.rb +83 -59
- data/lib/ibm_watson/compare_comply_v1.rb +11 -4
- data/lib/ibm_watson/discovery_v1.rb +5 -12
- data/lib/ibm_watson/discovery_v2.rb +201 -110
- data/lib/ibm_watson/language_translator_v3.rb +1 -2
- data/lib/ibm_watson/natural_language_classifier_v1.rb +14 -6
- data/lib/ibm_watson/natural_language_understanding_v1.rb +690 -3
- data/lib/ibm_watson/personality_insights_v3.rb +13 -11
- data/lib/ibm_watson/speech_to_text_v1.rb +582 -333
- data/lib/ibm_watson/text_to_speech_v1.rb +617 -35
- data/lib/ibm_watson/tone_analyzer_v3.rb +1 -2
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +1 -2
- data/lib/ibm_watson/visual_recognition_v4.rb +11 -8
- data/test/integration/test_discovery_v2.rb +15 -0
- data/test/integration/test_natural_language_understanding_v1.rb +134 -1
- data/test/integration/test_text_to_speech_v1.rb +57 -0
- data/test/unit/test_discovery_v2.rb +29 -0
- data/test/unit/test_natural_language_understanding_v1.rb +231 -0
- data/test/unit/test_text_to_speech_v1.rb +145 -0
- metadata +3 -3
@@ -14,7 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
-
# IBM OpenAPI SDK Code Generator Version: 3.
|
17
|
+
# IBM OpenAPI SDK Code Generator Version: 3.38.0-07189efd-20210827-205025
|
18
18
|
#
|
19
19
|
# IBM Watson™ Language Translator translates text from one language to another.
|
20
20
|
# The service offers multiple IBM-provided translation models that you can customize based
|
@@ -28,7 +28,6 @@ require "json"
|
|
28
28
|
require "ibm_cloud_sdk_core"
|
29
29
|
require_relative "./common.rb"
|
30
30
|
|
31
|
-
# Module for the Watson APIs
|
32
31
|
module IBMWatson
|
33
32
|
##
|
34
33
|
# The Language Translator V3 service.
|
@@ -14,12 +14,20 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
-
# IBM OpenAPI SDK Code Generator Version: 3.
|
17
|
+
# IBM OpenAPI SDK Code Generator Version: 3.38.0-07189efd-20210827-205025
|
18
18
|
#
|
19
|
-
# IBM Watson™ Natural Language
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
19
|
+
# On 9 August 2021, IBM announced the deprecation of IBM Watson™ Natural Language
|
20
|
+
# Classifier. As of 9 September 2021, you cannot create new instances. However, existing
|
21
|
+
# instances are supported until 8 August 2022. The service will no longer be available on
|
22
|
+
# 8 August 2022.<br/><br/>As an alternative, consider migrating to IBM Watson Natural
|
23
|
+
# Language Understanding. For more information, see [Migrating to Natural Language
|
24
|
+
# Understanding](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-migrating).
|
25
|
+
# {: deprecated}
|
26
|
+
#
|
27
|
+
# Natural Language Classifier uses machine learning algorithms to return the top matching
|
28
|
+
# predefined classes for short text input. You create and train a classifier to connect
|
29
|
+
# predefined classes to example texts so that the service can apply those classes to new
|
30
|
+
# inputs.
|
23
31
|
|
24
32
|
require "concurrent"
|
25
33
|
require "erb"
|
@@ -27,7 +35,6 @@ require "json"
|
|
27
35
|
require "ibm_cloud_sdk_core"
|
28
36
|
require_relative "./common.rb"
|
29
37
|
|
30
|
-
# Module for the Watson APIs
|
31
38
|
module IBMWatson
|
32
39
|
##
|
33
40
|
# The Natural Language Classifier V1 service.
|
@@ -46,6 +53,7 @@ module IBMWatson
|
|
46
53
|
# @option args service_name [String] The name of the service to configure. Will be used as the key to load
|
47
54
|
# any external configuration, if applicable.
|
48
55
|
def initialize(args = {})
|
56
|
+
warn "On 9 August 2021, IBM announced the deprecation of the Natural Language Classifier service. The service will no longer be available from 8 August 2022. As of 9 September 2021, you will not be able to create new instances. Existing instances will be supported until 8 August 2022. Any instance that still exists on that date will be deleted. For more information, see https://github.com/watson-developer-cloud/ruby-sdk#natural-language-classifier-deprecation."
|
49
57
|
@__async_initialized__ = false
|
50
58
|
defaults = {}
|
51
59
|
defaults[:service_url] = DEFAULT_SERVICE_URL
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
|
-
# IBM OpenAPI SDK Code Generator Version: 3.
|
17
|
+
# IBM OpenAPI SDK Code Generator Version: 3.38.0-07189efd-20210827-205025
|
18
18
|
#
|
19
19
|
# Analyze various features of text content at scale. Provide text, raw HTML, or a public
|
20
20
|
# URL and IBM Watson Natural Language Understanding will give you results for the features
|
@@ -32,7 +32,6 @@ require "json"
|
|
32
32
|
require "ibm_cloud_sdk_core"
|
33
33
|
require_relative "./common.rb"
|
34
34
|
|
35
|
-
# Module for the Watson APIs
|
36
35
|
module IBMWatson
|
37
36
|
##
|
38
37
|
# The Natural Language Understanding V1 service.
|
@@ -47,7 +46,7 @@ module IBMWatson
|
|
47
46
|
#
|
48
47
|
# @param args [Hash] The args to initialize with
|
49
48
|
# @option args version [String] Release date of the API version you want to use. Specify dates in YYYY-MM-DD
|
50
|
-
# format. The current version is `
|
49
|
+
# format. The current version is `2021-08-01`.
|
51
50
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
52
51
|
# The base service_url may differ between IBM Cloud regions.
|
53
52
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
@@ -79,6 +78,7 @@ module IBMWatson
|
|
79
78
|
# Analyze text.
|
80
79
|
# Analyzes text, HTML, or a public webpage for the following features:
|
81
80
|
# - Categories
|
81
|
+
# - Classifications
|
82
82
|
# - Concepts
|
83
83
|
# - Emotion
|
84
84
|
# - Entities
|
@@ -212,6 +212,693 @@ module IBMWatson
|
|
212
212
|
|
213
213
|
method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
|
214
214
|
|
215
|
+
response = request(
|
216
|
+
method: "DELETE",
|
217
|
+
url: method_url,
|
218
|
+
headers: headers,
|
219
|
+
params: params,
|
220
|
+
accept_json: true
|
221
|
+
)
|
222
|
+
response
|
223
|
+
end
|
224
|
+
#########################
|
225
|
+
# Manage sentiment models
|
226
|
+
#########################
|
227
|
+
|
228
|
+
##
|
229
|
+
# @!method create_sentiment_model(language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
230
|
+
# Create sentiment model.
|
231
|
+
# (Beta) Creates a custom sentiment model by uploading training data and associated
|
232
|
+
# metadata. The model begins the training and deploying process and is ready to use
|
233
|
+
# when the `status` is `available`.
|
234
|
+
# @param language [String] The 2-letter language code of this model.
|
235
|
+
# @param training_data [File] Training data in CSV format. For more information, see [Sentiment training data
|
236
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
|
237
|
+
# @param name [String] An optional name for the model.
|
238
|
+
# @param description [String] An optional description of the model.
|
239
|
+
# @param model_version [String] An optional version string.
|
240
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
241
|
+
# Language Understanding.
|
242
|
+
# @param version_description [String] The description of the version.
|
243
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
244
|
+
def create_sentiment_model(language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
245
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
246
|
+
|
247
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
248
|
+
|
249
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
250
|
+
|
251
|
+
headers = {
|
252
|
+
}
|
253
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_sentiment_model")
|
254
|
+
headers.merge!(sdk_headers)
|
255
|
+
|
256
|
+
params = {
|
257
|
+
"version" => @version
|
258
|
+
}
|
259
|
+
|
260
|
+
form_data = {}
|
261
|
+
|
262
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
263
|
+
|
264
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
265
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
266
|
+
end
|
267
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: "text/csv", filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
268
|
+
|
269
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
270
|
+
|
271
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
272
|
+
|
273
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
274
|
+
|
275
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
276
|
+
|
277
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
278
|
+
|
279
|
+
method_url = "/v1/models/sentiment"
|
280
|
+
|
281
|
+
response = request(
|
282
|
+
method: "POST",
|
283
|
+
url: method_url,
|
284
|
+
headers: headers,
|
285
|
+
params: params,
|
286
|
+
form: form_data,
|
287
|
+
accept_json: true
|
288
|
+
)
|
289
|
+
response
|
290
|
+
end
|
291
|
+
|
292
|
+
##
|
293
|
+
# @!method list_sentiment_models
|
294
|
+
# List sentiment models.
|
295
|
+
# (Beta) Returns all custom sentiment models associated with this service instance.
|
296
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
297
|
+
def list_sentiment_models
|
298
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
299
|
+
|
300
|
+
headers = {
|
301
|
+
}
|
302
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_sentiment_models")
|
303
|
+
headers.merge!(sdk_headers)
|
304
|
+
|
305
|
+
params = {
|
306
|
+
"version" => @version
|
307
|
+
}
|
308
|
+
|
309
|
+
method_url = "/v1/models/sentiment"
|
310
|
+
|
311
|
+
response = request(
|
312
|
+
method: "GET",
|
313
|
+
url: method_url,
|
314
|
+
headers: headers,
|
315
|
+
params: params,
|
316
|
+
accept_json: true
|
317
|
+
)
|
318
|
+
response
|
319
|
+
end
|
320
|
+
|
321
|
+
##
|
322
|
+
# @!method get_sentiment_model(model_id:)
|
323
|
+
# Get sentiment model details.
|
324
|
+
# (Beta) Returns the status of the sentiment model with the given model ID.
|
325
|
+
# @param model_id [String] ID of the model.
|
326
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
327
|
+
def get_sentiment_model(model_id:)
|
328
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
329
|
+
|
330
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
331
|
+
|
332
|
+
headers = {
|
333
|
+
}
|
334
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_sentiment_model")
|
335
|
+
headers.merge!(sdk_headers)
|
336
|
+
|
337
|
+
params = {
|
338
|
+
"version" => @version
|
339
|
+
}
|
340
|
+
|
341
|
+
method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
|
342
|
+
|
343
|
+
response = request(
|
344
|
+
method: "GET",
|
345
|
+
url: method_url,
|
346
|
+
headers: headers,
|
347
|
+
params: params,
|
348
|
+
accept_json: true
|
349
|
+
)
|
350
|
+
response
|
351
|
+
end
|
352
|
+
|
353
|
+
##
|
354
|
+
# @!method update_sentiment_model(model_id:, language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
355
|
+
# Update sentiment model.
|
356
|
+
# (Beta) Overwrites the training data associated with this custom sentiment model
|
357
|
+
# and retrains the model. The new model replaces the current deployment.
|
358
|
+
# @param model_id [String] ID of the model.
|
359
|
+
# @param language [String] The 2-letter language code of this model.
|
360
|
+
# @param training_data [File] Training data in CSV format. For more information, see [Sentiment training data
|
361
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-custom-sentiment#sentiment-training-data-requirements).
|
362
|
+
# @param name [String] An optional name for the model.
|
363
|
+
# @param description [String] An optional description of the model.
|
364
|
+
# @param model_version [String] An optional version string.
|
365
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
366
|
+
# Language Understanding.
|
367
|
+
# @param version_description [String] The description of the version.
|
368
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
369
|
+
def update_sentiment_model(model_id:, language:, training_data:, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
370
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
371
|
+
|
372
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
373
|
+
|
374
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
375
|
+
|
376
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
377
|
+
|
378
|
+
headers = {
|
379
|
+
}
|
380
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_sentiment_model")
|
381
|
+
headers.merge!(sdk_headers)
|
382
|
+
|
383
|
+
params = {
|
384
|
+
"version" => @version
|
385
|
+
}
|
386
|
+
|
387
|
+
form_data = {}
|
388
|
+
|
389
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
390
|
+
|
391
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
392
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
393
|
+
end
|
394
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: "text/csv", filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
395
|
+
|
396
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
397
|
+
|
398
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
399
|
+
|
400
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
401
|
+
|
402
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
403
|
+
|
404
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
405
|
+
|
406
|
+
method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
|
407
|
+
|
408
|
+
response = request(
|
409
|
+
method: "PUT",
|
410
|
+
url: method_url,
|
411
|
+
headers: headers,
|
412
|
+
params: params,
|
413
|
+
form: form_data,
|
414
|
+
accept_json: true
|
415
|
+
)
|
416
|
+
response
|
417
|
+
end
|
418
|
+
|
419
|
+
##
|
420
|
+
# @!method delete_sentiment_model(model_id:)
|
421
|
+
# Delete sentiment model.
|
422
|
+
# (Beta) Un-deploys the custom sentiment model with the given model ID and deletes
|
423
|
+
# all associated customer data, including any training data or binary artifacts.
|
424
|
+
# @param model_id [String] ID of the model.
|
425
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
426
|
+
def delete_sentiment_model(model_id:)
|
427
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
428
|
+
|
429
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
430
|
+
|
431
|
+
headers = {
|
432
|
+
}
|
433
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_sentiment_model")
|
434
|
+
headers.merge!(sdk_headers)
|
435
|
+
|
436
|
+
params = {
|
437
|
+
"version" => @version
|
438
|
+
}
|
439
|
+
|
440
|
+
method_url = "/v1/models/sentiment/%s" % [ERB::Util.url_encode(model_id)]
|
441
|
+
|
442
|
+
response = request(
|
443
|
+
method: "DELETE",
|
444
|
+
url: method_url,
|
445
|
+
headers: headers,
|
446
|
+
params: params,
|
447
|
+
accept_json: true
|
448
|
+
)
|
449
|
+
response
|
450
|
+
end
|
451
|
+
#########################
|
452
|
+
# Manage categories models
|
453
|
+
#########################
|
454
|
+
|
455
|
+
##
|
456
|
+
# @!method create_categories_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
457
|
+
# Create categories model.
|
458
|
+
# (Beta) Creates a custom categories model by uploading training data and associated
|
459
|
+
# metadata. The model begins the training and deploying process and is ready to use
|
460
|
+
# when the `status` is `available`.
|
461
|
+
# @param language [String] The 2-letter language code of this model.
|
462
|
+
# @param training_data [File] Training data in JSON format. For more information, see [Categories training data
|
463
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
|
464
|
+
# @param training_data_content_type [String] The content type of training_data.
|
465
|
+
# @param name [String] An optional name for the model.
|
466
|
+
# @param description [String] An optional description of the model.
|
467
|
+
# @param model_version [String] An optional version string.
|
468
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
469
|
+
# Language Understanding.
|
470
|
+
# @param version_description [String] The description of the version.
|
471
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
472
|
+
def create_categories_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
473
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
474
|
+
|
475
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
476
|
+
|
477
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
478
|
+
|
479
|
+
headers = {
|
480
|
+
}
|
481
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_categories_model")
|
482
|
+
headers.merge!(sdk_headers)
|
483
|
+
|
484
|
+
params = {
|
485
|
+
"version" => @version
|
486
|
+
}
|
487
|
+
|
488
|
+
form_data = {}
|
489
|
+
|
490
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
491
|
+
|
492
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
493
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
494
|
+
end
|
495
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
496
|
+
|
497
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
498
|
+
|
499
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
500
|
+
|
501
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
502
|
+
|
503
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
504
|
+
|
505
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
506
|
+
|
507
|
+
method_url = "/v1/models/categories"
|
508
|
+
|
509
|
+
response = request(
|
510
|
+
method: "POST",
|
511
|
+
url: method_url,
|
512
|
+
headers: headers,
|
513
|
+
params: params,
|
514
|
+
form: form_data,
|
515
|
+
accept_json: true
|
516
|
+
)
|
517
|
+
response
|
518
|
+
end
|
519
|
+
|
520
|
+
##
|
521
|
+
# @!method list_categories_models
|
522
|
+
# List categories models.
|
523
|
+
# (Beta) Returns all custom categories models associated with this service instance.
|
524
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
525
|
+
def list_categories_models
|
526
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
527
|
+
|
528
|
+
headers = {
|
529
|
+
}
|
530
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_categories_models")
|
531
|
+
headers.merge!(sdk_headers)
|
532
|
+
|
533
|
+
params = {
|
534
|
+
"version" => @version
|
535
|
+
}
|
536
|
+
|
537
|
+
method_url = "/v1/models/categories"
|
538
|
+
|
539
|
+
response = request(
|
540
|
+
method: "GET",
|
541
|
+
url: method_url,
|
542
|
+
headers: headers,
|
543
|
+
params: params,
|
544
|
+
accept_json: true
|
545
|
+
)
|
546
|
+
response
|
547
|
+
end
|
548
|
+
|
549
|
+
##
|
550
|
+
# @!method get_categories_model(model_id:)
|
551
|
+
# Get categories model details.
|
552
|
+
# (Beta) Returns the status of the categories model with the given model ID.
|
553
|
+
# @param model_id [String] ID of the model.
|
554
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
555
|
+
def get_categories_model(model_id:)
|
556
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
557
|
+
|
558
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
559
|
+
|
560
|
+
headers = {
|
561
|
+
}
|
562
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_categories_model")
|
563
|
+
headers.merge!(sdk_headers)
|
564
|
+
|
565
|
+
params = {
|
566
|
+
"version" => @version
|
567
|
+
}
|
568
|
+
|
569
|
+
method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
|
570
|
+
|
571
|
+
response = request(
|
572
|
+
method: "GET",
|
573
|
+
url: method_url,
|
574
|
+
headers: headers,
|
575
|
+
params: params,
|
576
|
+
accept_json: true
|
577
|
+
)
|
578
|
+
response
|
579
|
+
end
|
580
|
+
|
581
|
+
##
|
582
|
+
# @!method update_categories_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
583
|
+
# Update categories model.
|
584
|
+
# (Beta) Overwrites the training data associated with this custom categories model
|
585
|
+
# and retrains the model. The new model replaces the current deployment.
|
586
|
+
# @param model_id [String] ID of the model.
|
587
|
+
# @param language [String] The 2-letter language code of this model.
|
588
|
+
# @param training_data [File] Training data in JSON format. For more information, see [Categories training data
|
589
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-categories##categories-training-data-requirements).
|
590
|
+
# @param training_data_content_type [String] The content type of training_data.
|
591
|
+
# @param name [String] An optional name for the model.
|
592
|
+
# @param description [String] An optional description of the model.
|
593
|
+
# @param model_version [String] An optional version string.
|
594
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
595
|
+
# Language Understanding.
|
596
|
+
# @param version_description [String] The description of the version.
|
597
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
598
|
+
def update_categories_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
599
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
600
|
+
|
601
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
602
|
+
|
603
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
604
|
+
|
605
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
606
|
+
|
607
|
+
headers = {
|
608
|
+
}
|
609
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_categories_model")
|
610
|
+
headers.merge!(sdk_headers)
|
611
|
+
|
612
|
+
params = {
|
613
|
+
"version" => @version
|
614
|
+
}
|
615
|
+
|
616
|
+
form_data = {}
|
617
|
+
|
618
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
619
|
+
|
620
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
621
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
622
|
+
end
|
623
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
624
|
+
|
625
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
626
|
+
|
627
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
628
|
+
|
629
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
630
|
+
|
631
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
632
|
+
|
633
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
634
|
+
|
635
|
+
method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
|
636
|
+
|
637
|
+
response = request(
|
638
|
+
method: "PUT",
|
639
|
+
url: method_url,
|
640
|
+
headers: headers,
|
641
|
+
params: params,
|
642
|
+
form: form_data,
|
643
|
+
accept_json: true
|
644
|
+
)
|
645
|
+
response
|
646
|
+
end
|
647
|
+
|
648
|
+
##
|
649
|
+
# @!method delete_categories_model(model_id:)
|
650
|
+
# Delete categories model.
|
651
|
+
# (Beta) Un-deploys the custom categories model with the given model ID and deletes
|
652
|
+
# all associated customer data, including any training data or binary artifacts.
|
653
|
+
# @param model_id [String] ID of the model.
|
654
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
655
|
+
def delete_categories_model(model_id:)
|
656
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
657
|
+
|
658
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
659
|
+
|
660
|
+
headers = {
|
661
|
+
}
|
662
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_categories_model")
|
663
|
+
headers.merge!(sdk_headers)
|
664
|
+
|
665
|
+
params = {
|
666
|
+
"version" => @version
|
667
|
+
}
|
668
|
+
|
669
|
+
method_url = "/v1/models/categories/%s" % [ERB::Util.url_encode(model_id)]
|
670
|
+
|
671
|
+
response = request(
|
672
|
+
method: "DELETE",
|
673
|
+
url: method_url,
|
674
|
+
headers: headers,
|
675
|
+
params: params,
|
676
|
+
accept_json: true
|
677
|
+
)
|
678
|
+
response
|
679
|
+
end
|
680
|
+
#########################
|
681
|
+
# Manage classifications models
|
682
|
+
#########################
|
683
|
+
|
684
|
+
##
|
685
|
+
# @!method create_classifications_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
686
|
+
# Create classifications model.
|
687
|
+
# Creates a custom classifications model by uploading training data and associated
|
688
|
+
# metadata. The model begins the training and deploying process and is ready to use
|
689
|
+
# when the `status` is `available`.
|
690
|
+
# @param language [String] The 2-letter language code of this model.
|
691
|
+
# @param training_data [File] Training data in JSON format. For more information, see [Classifications training
|
692
|
+
# data
|
693
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
|
694
|
+
# @param training_data_content_type [String] The content type of training_data.
|
695
|
+
# @param name [String] An optional name for the model.
|
696
|
+
# @param description [String] An optional description of the model.
|
697
|
+
# @param model_version [String] An optional version string.
|
698
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
699
|
+
# Language Understanding.
|
700
|
+
# @param version_description [String] The description of the version.
|
701
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
702
|
+
def create_classifications_model(language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
703
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
704
|
+
|
705
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
706
|
+
|
707
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
708
|
+
|
709
|
+
headers = {
|
710
|
+
}
|
711
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "create_classifications_model")
|
712
|
+
headers.merge!(sdk_headers)
|
713
|
+
|
714
|
+
params = {
|
715
|
+
"version" => @version
|
716
|
+
}
|
717
|
+
|
718
|
+
form_data = {}
|
719
|
+
|
720
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
721
|
+
|
722
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
723
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
724
|
+
end
|
725
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
726
|
+
|
727
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
728
|
+
|
729
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
730
|
+
|
731
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
732
|
+
|
733
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
734
|
+
|
735
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
736
|
+
|
737
|
+
method_url = "/v1/models/classifications"
|
738
|
+
|
739
|
+
response = request(
|
740
|
+
method: "POST",
|
741
|
+
url: method_url,
|
742
|
+
headers: headers,
|
743
|
+
params: params,
|
744
|
+
form: form_data,
|
745
|
+
accept_json: true
|
746
|
+
)
|
747
|
+
response
|
748
|
+
end
|
749
|
+
|
750
|
+
##
|
751
|
+
# @!method list_classifications_models
|
752
|
+
# List classifications models.
|
753
|
+
# Returns all custom classifications models associated with this service instance.
|
754
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
755
|
+
def list_classifications_models
|
756
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
757
|
+
|
758
|
+
headers = {
|
759
|
+
}
|
760
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_classifications_models")
|
761
|
+
headers.merge!(sdk_headers)
|
762
|
+
|
763
|
+
params = {
|
764
|
+
"version" => @version
|
765
|
+
}
|
766
|
+
|
767
|
+
method_url = "/v1/models/classifications"
|
768
|
+
|
769
|
+
response = request(
|
770
|
+
method: "GET",
|
771
|
+
url: method_url,
|
772
|
+
headers: headers,
|
773
|
+
params: params,
|
774
|
+
accept_json: true
|
775
|
+
)
|
776
|
+
response
|
777
|
+
end
|
778
|
+
|
779
|
+
##
|
780
|
+
# @!method get_classifications_model(model_id:)
|
781
|
+
# Get classifications model details.
|
782
|
+
# Returns the status of the classifications model with the given model ID.
|
783
|
+
# @param model_id [String] ID of the model.
|
784
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
785
|
+
def get_classifications_model(model_id:)
|
786
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
787
|
+
|
788
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
789
|
+
|
790
|
+
headers = {
|
791
|
+
}
|
792
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "get_classifications_model")
|
793
|
+
headers.merge!(sdk_headers)
|
794
|
+
|
795
|
+
params = {
|
796
|
+
"version" => @version
|
797
|
+
}
|
798
|
+
|
799
|
+
method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
|
800
|
+
|
801
|
+
response = request(
|
802
|
+
method: "GET",
|
803
|
+
url: method_url,
|
804
|
+
headers: headers,
|
805
|
+
params: params,
|
806
|
+
accept_json: true
|
807
|
+
)
|
808
|
+
response
|
809
|
+
end
|
810
|
+
|
811
|
+
##
|
812
|
+
# @!method update_classifications_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
813
|
+
# Update classifications model.
|
814
|
+
# Overwrites the training data associated with this custom classifications model and
|
815
|
+
# retrains the model. The new model replaces the current deployment.
|
816
|
+
# @param model_id [String] ID of the model.
|
817
|
+
# @param language [String] The 2-letter language code of this model.
|
818
|
+
# @param training_data [File] Training data in JSON format. For more information, see [Classifications training
|
819
|
+
# data
|
820
|
+
# requirements](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications#classification-training-data-requirements).
|
821
|
+
# @param training_data_content_type [String] The content type of training_data.
|
822
|
+
# @param name [String] An optional name for the model.
|
823
|
+
# @param description [String] An optional description of the model.
|
824
|
+
# @param model_version [String] An optional version string.
|
825
|
+
# @param workspace_id [String] ID of the Watson Knowledge Studio workspace that deployed this model to Natural
|
826
|
+
# Language Understanding.
|
827
|
+
# @param version_description [String] The description of the version.
|
828
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
829
|
+
def update_classifications_model(model_id:, language:, training_data:, training_data_content_type: nil, name: nil, description: nil, model_version: nil, workspace_id: nil, version_description: nil)
|
830
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
831
|
+
|
832
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
833
|
+
|
834
|
+
raise ArgumentError.new("language must be provided") if language.nil?
|
835
|
+
|
836
|
+
raise ArgumentError.new("training_data must be provided") if training_data.nil?
|
837
|
+
|
838
|
+
headers = {
|
839
|
+
}
|
840
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "update_classifications_model")
|
841
|
+
headers.merge!(sdk_headers)
|
842
|
+
|
843
|
+
params = {
|
844
|
+
"version" => @version
|
845
|
+
}
|
846
|
+
|
847
|
+
form_data = {}
|
848
|
+
|
849
|
+
form_data[:language] = HTTP::FormData::Part.new(language.to_s, content_type: "text/plain")
|
850
|
+
|
851
|
+
unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
|
852
|
+
training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
|
853
|
+
end
|
854
|
+
form_data[:training_data] = HTTP::FormData::File.new(training_data, content_type: training_data_content_type.nil? ? "application/octet-stream" : training_data_content_type, filename: training_data.respond_to?(:path) ? training_data.path : nil)
|
855
|
+
|
856
|
+
form_data[:name] = HTTP::FormData::Part.new(name.to_s, content_type: "text/plain") unless name.nil?
|
857
|
+
|
858
|
+
form_data[:description] = HTTP::FormData::Part.new(description.to_s, content_type: "text/plain") unless description.nil?
|
859
|
+
|
860
|
+
form_data[:model_version] = HTTP::FormData::Part.new(model_version.to_s, content_type: "text/plain") unless model_version.nil?
|
861
|
+
|
862
|
+
form_data[:workspace_id] = HTTP::FormData::Part.new(workspace_id.to_s, content_type: "text/plain") unless workspace_id.nil?
|
863
|
+
|
864
|
+
form_data[:version_description] = HTTP::FormData::Part.new(version_description.to_s, content_type: "text/plain") unless version_description.nil?
|
865
|
+
|
866
|
+
method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
|
867
|
+
|
868
|
+
response = request(
|
869
|
+
method: "PUT",
|
870
|
+
url: method_url,
|
871
|
+
headers: headers,
|
872
|
+
params: params,
|
873
|
+
form: form_data,
|
874
|
+
accept_json: true
|
875
|
+
)
|
876
|
+
response
|
877
|
+
end
|
878
|
+
|
879
|
+
##
|
880
|
+
# @!method delete_classifications_model(model_id:)
|
881
|
+
# Delete classifications model.
|
882
|
+
# Un-deploys the custom classifications model with the given model ID and deletes
|
883
|
+
# all associated customer data, including any training data or binary artifacts.
|
884
|
+
# @param model_id [String] ID of the model.
|
885
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
886
|
+
def delete_classifications_model(model_id:)
|
887
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
888
|
+
|
889
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
890
|
+
|
891
|
+
headers = {
|
892
|
+
}
|
893
|
+
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "delete_classifications_model")
|
894
|
+
headers.merge!(sdk_headers)
|
895
|
+
|
896
|
+
params = {
|
897
|
+
"version" => @version
|
898
|
+
}
|
899
|
+
|
900
|
+
method_url = "/v1/models/classifications/%s" % [ERB::Util.url_encode(model_id)]
|
901
|
+
|
215
902
|
response = request(
|
216
903
|
method: "DELETE",
|
217
904
|
url: method_url,
|