ibm_watson 0.16.1 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -12
- data/lib/ibm_watson/assistant_v1.rb +745 -720
- data/lib/ibm_watson/assistant_v2.rb +23 -19
- data/lib/ibm_watson/compare_comply_v1.rb +94 -89
- data/lib/ibm_watson/discovery_v1.rb +684 -687
- data/lib/ibm_watson/language_translator_v3.rb +234 -33
- data/lib/ibm_watson/natural_language_classifier_v1.rb +33 -29
- data/lib/ibm_watson/natural_language_understanding_v1.rb +33 -29
- data/lib/ibm_watson/personality_insights_v3.rb +18 -14
- data/lib/ibm_watson/speech_to_text_v1.rb +799 -725
- data/lib/ibm_watson/text_to_speech_v1.rb +201 -196
- data/lib/ibm_watson/tone_analyzer_v3.rb +15 -11
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +52 -48
- data/test/integration/test_language_translator_v3.rb +37 -1
- data/test/unit/test_language_translator_v3.rb +201 -16
- data/test/unit/test_speech_to_text_v1.rb +2 -2
- metadata +5 -5
@@ -15,7 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
# The IBM Watson™ Assistant service combines machine learning, natural language
|
18
|
-
# understanding, and integrated dialog
|
18
|
+
# understanding, and an integrated dialog editor to create conversation flows between your
|
19
19
|
# apps and your users.
|
20
20
|
|
21
21
|
require "concurrent"
|
@@ -47,16 +47,16 @@ module IBMWatson
|
|
47
47
|
# ready for a later version.
|
48
48
|
# @option args url [String] The base url to use when contacting the service (e.g.
|
49
49
|
# "https://gateway.watsonplatform.net/assistant/api").
|
50
|
-
# The base url may differ between
|
50
|
+
# The base url may differ between IBM Cloud regions.
|
51
51
|
# @option args username [String] The username used to authenticate with the service.
|
52
52
|
# Username and password credentials are only required to run your
|
53
|
-
# application locally or outside of
|
54
|
-
#
|
53
|
+
# application locally or outside of IBM Cloud. When running on
|
54
|
+
# IBM Cloud, the credentials will be automatically loaded from the
|
55
55
|
# `VCAP_SERVICES` environment variable.
|
56
56
|
# @option args password [String] The password used to authenticate with the service.
|
57
57
|
# Username and password credentials are only required to run your
|
58
|
-
# application locally or outside of
|
59
|
-
#
|
58
|
+
# application locally or outside of IBM Cloud. When running on
|
59
|
+
# IBM Cloud, the credentials will be automatically loaded from the
|
60
60
|
# `VCAP_SERVICES` environment variable.
|
61
61
|
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
62
62
|
# this API key is provided, the SDK will manage the token and handle the
|
@@ -66,7 +66,9 @@ module IBMWatson
|
|
66
66
|
# it expires or reactively upon receiving a 401 from the service as any requests
|
67
67
|
# made with an expired token will fail.
|
68
68
|
# @option args iam_url [String] An optional URL for the IAM service API. Defaults to
|
69
|
-
# 'https://iam.
|
69
|
+
# 'https://iam.cloud.ibm.com/identity/token'.
|
70
|
+
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
71
|
+
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
70
72
|
def initialize(args = {})
|
71
73
|
@__async_initialized__ = false
|
72
74
|
defaults = {}
|
@@ -77,6 +79,8 @@ module IBMWatson
|
|
77
79
|
defaults[:iam_apikey] = nil
|
78
80
|
defaults[:iam_access_token] = nil
|
79
81
|
defaults[:iam_url] = nil
|
82
|
+
defaults[:iam_client_id] = nil
|
83
|
+
defaults[:iam_client_secret] = nil
|
80
84
|
args = defaults.merge(args)
|
81
85
|
args[:vcap_services_name] = "conversation"
|
82
86
|
super
|
@@ -93,10 +97,10 @@ module IBMWatson
|
|
93
97
|
# Create a session.
|
94
98
|
# Create a new session. A session is used to send user input to a skill and receive
|
95
99
|
# responses. It also maintains the state of the conversation.
|
96
|
-
# @param assistant_id [String] Unique identifier of the assistant.
|
97
|
-
#
|
98
|
-
# creating assistants, see the
|
99
|
-
# [documentation](https://
|
100
|
+
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
101
|
+
# Assistant user interface, open the assistant settings and click **API Details**.
|
102
|
+
# For information about creating assistants, see the
|
103
|
+
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
|
100
104
|
#
|
101
105
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
102
106
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
@@ -128,10 +132,10 @@ module IBMWatson
|
|
128
132
|
# @!method delete_session(assistant_id:, session_id:)
|
129
133
|
# Delete session.
|
130
134
|
# Deletes a session explicitly before it times out.
|
131
|
-
# @param assistant_id [String] Unique identifier of the assistant.
|
132
|
-
#
|
133
|
-
# creating assistants, see the
|
134
|
-
# [documentation](https://
|
135
|
+
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
136
|
+
# Assistant user interface, open the assistant settings and click **API Details**.
|
137
|
+
# For information about creating assistants, see the
|
138
|
+
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
|
135
139
|
#
|
136
140
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
137
141
|
# @param session_id [String] Unique identifier of the session.
|
@@ -171,10 +175,10 @@ module IBMWatson
|
|
171
175
|
# Send user input to an assistant and receive a response.
|
172
176
|
#
|
173
177
|
# There is no rate limit for this operation.
|
174
|
-
# @param assistant_id [String] Unique identifier of the assistant.
|
175
|
-
#
|
176
|
-
# creating assistants, see the
|
177
|
-
# [documentation](https://
|
178
|
+
# @param assistant_id [String] Unique identifier of the assistant. To find the assistant ID in the Watson
|
179
|
+
# Assistant user interface, open the assistant settings and click **API Details**.
|
180
|
+
# For information about creating assistants, see the
|
181
|
+
# [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-add#assistant-add-task).
|
178
182
|
#
|
179
183
|
# **Note:** Currently, the v2 API does not support creating assistants.
|
180
184
|
# @param session_id [String] Unique identifier of the session.
|
@@ -46,7 +46,7 @@ module IBMWatson
|
|
46
46
|
# ready for a later version.
|
47
47
|
# @option args url [String] The base url to use when contacting the service (e.g.
|
48
48
|
# "https://gateway.watsonplatform.net/compare-comply/api").
|
49
|
-
# The base url may differ between
|
49
|
+
# The base url may differ between IBM Cloud regions.
|
50
50
|
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
51
51
|
# this API key is provided, the SDK will manage the token and handle the
|
52
52
|
# refreshing.
|
@@ -55,7 +55,9 @@ module IBMWatson
|
|
55
55
|
# it expires or reactively upon receiving a 401 from the service as any requests
|
56
56
|
# made with an expired token will fail.
|
57
57
|
# @option args iam_url [String] An optional URL for the IAM service API. Defaults to
|
58
|
-
# 'https://iam.
|
58
|
+
# 'https://iam.cloud.ibm.com/identity/token'.
|
59
|
+
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
60
|
+
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
59
61
|
def initialize(args = {})
|
60
62
|
@__async_initialized__ = false
|
61
63
|
defaults = {}
|
@@ -64,6 +66,8 @@ module IBMWatson
|
|
64
66
|
defaults[:iam_apikey] = nil
|
65
67
|
defaults[:iam_access_token] = nil
|
66
68
|
defaults[:iam_url] = nil
|
69
|
+
defaults[:iam_client_id] = nil
|
70
|
+
defaults[:iam_client_secret] = nil
|
67
71
|
args = defaults.merge(args)
|
68
72
|
args[:vcap_services_name] = "compare-comply"
|
69
73
|
super
|
@@ -321,76 +325,6 @@ module IBMWatson
|
|
321
325
|
response
|
322
326
|
end
|
323
327
|
|
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
|
-
|
394
328
|
##
|
395
329
|
# @!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)
|
396
330
|
# List the feedback in a document.
|
@@ -474,6 +408,76 @@ module IBMWatson
|
|
474
408
|
)
|
475
409
|
response
|
476
410
|
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# @!method get_feedback(feedback_id:, model: nil)
|
414
|
+
# Get a specified feedback entry.
|
415
|
+
# Gets a feedback entry with a specified `feedback_id`.
|
416
|
+
# @param feedback_id [String] A string that specifies the feedback entry to be included in the output.
|
417
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
418
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
419
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
420
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
421
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
422
|
+
def get_feedback(feedback_id:, model: nil)
|
423
|
+
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
424
|
+
|
425
|
+
headers = {
|
426
|
+
}
|
427
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_feedback")
|
428
|
+
headers.merge!(sdk_headers)
|
429
|
+
|
430
|
+
params = {
|
431
|
+
"version" => @version,
|
432
|
+
"model" => model
|
433
|
+
}
|
434
|
+
|
435
|
+
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
436
|
+
|
437
|
+
response = request(
|
438
|
+
method: "GET",
|
439
|
+
url: method_url,
|
440
|
+
headers: headers,
|
441
|
+
params: params,
|
442
|
+
accept_json: true
|
443
|
+
)
|
444
|
+
response
|
445
|
+
end
|
446
|
+
|
447
|
+
##
|
448
|
+
# @!method delete_feedback(feedback_id:, model: nil)
|
449
|
+
# Delete a specified feedback entry.
|
450
|
+
# Deletes a feedback entry with a specified `feedback_id`.
|
451
|
+
# @param feedback_id [String] A string that specifies the feedback entry to be deleted from the document.
|
452
|
+
# @param model [String] The analysis model to be used by the service. For the **Element classification**
|
453
|
+
# and **Compare two documents** methods, the default is `contracts`. For the
|
454
|
+
# **Extract tables** method, the default is `tables`. These defaults apply to the
|
455
|
+
# standalone methods as well as to the methods' use in batch-processing requests.
|
456
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
457
|
+
def delete_feedback(feedback_id:, model: nil)
|
458
|
+
raise ArgumentError.new("feedback_id must be provided") if feedback_id.nil?
|
459
|
+
|
460
|
+
headers = {
|
461
|
+
}
|
462
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "delete_feedback")
|
463
|
+
headers.merge!(sdk_headers)
|
464
|
+
|
465
|
+
params = {
|
466
|
+
"version" => @version,
|
467
|
+
"model" => model
|
468
|
+
}
|
469
|
+
|
470
|
+
method_url = "/v1/feedback/%s" % [ERB::Util.url_encode(feedback_id)]
|
471
|
+
|
472
|
+
response = request(
|
473
|
+
method: "DELETE",
|
474
|
+
url: method_url,
|
475
|
+
headers: headers,
|
476
|
+
params: params,
|
477
|
+
accept_json: true
|
478
|
+
)
|
479
|
+
response
|
480
|
+
end
|
477
481
|
#########################
|
478
482
|
# Batches
|
479
483
|
#########################
|
@@ -482,11 +486,12 @@ module IBMWatson
|
|
482
486
|
# @!method create_batch(function:, input_credentials_file:, input_bucket_location:, input_bucket_name:, output_credentials_file:, output_bucket_location:, output_bucket_name:, model: nil)
|
483
487
|
# Submit a batch-processing request.
|
484
488
|
# Run Compare and Comply methods over a collection of input documents.
|
489
|
+
#
|
485
490
|
# **Important:** Batch processing requires the use of the [IBM Cloud Object Storage
|
486
|
-
# service](https://cloud.ibm.com/docs/services/cloud-object-storage
|
491
|
+
# service](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage).
|
487
492
|
# The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using
|
488
493
|
# batch
|
489
|
-
# processing](https://cloud.ibm.com/docs/services/compare-comply
|
494
|
+
# processing](https://cloud.ibm.com/docs/services/compare-comply?topic=compare-comply-batching#before-you-batch).
|
490
495
|
# @param function [String] The Compare and Comply method to run across the submitted input documents.
|
491
496
|
# @param input_credentials_file [File] A JSON file containing the input Cloud Object Storage credentials. At a minimum,
|
492
497
|
# the credentials must enable `READ` permissions on the bucket defined by the
|
@@ -567,24 +572,21 @@ module IBMWatson
|
|
567
572
|
end
|
568
573
|
|
569
574
|
##
|
570
|
-
# @!method
|
571
|
-
#
|
572
|
-
#
|
573
|
-
# @param batch_id [String] The ID of the batch-processing job whose information you want to retrieve.
|
575
|
+
# @!method list_batches
|
576
|
+
# List submitted batch-processing jobs.
|
577
|
+
# Lists batch-processing jobs submitted by users.
|
574
578
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
575
|
-
def
|
576
|
-
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
577
|
-
|
579
|
+
def list_batches
|
578
580
|
headers = {
|
579
581
|
}
|
580
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "
|
582
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "list_batches")
|
581
583
|
headers.merge!(sdk_headers)
|
582
584
|
|
583
585
|
params = {
|
584
586
|
"version" => @version
|
585
587
|
}
|
586
588
|
|
587
|
-
method_url = "/v1/batches
|
589
|
+
method_url = "/v1/batches"
|
588
590
|
|
589
591
|
response = request(
|
590
592
|
method: "GET",
|
@@ -597,21 +599,24 @@ module IBMWatson
|
|
597
599
|
end
|
598
600
|
|
599
601
|
##
|
600
|
-
# @!method
|
601
|
-
#
|
602
|
-
#
|
602
|
+
# @!method get_batch(batch_id:)
|
603
|
+
# Get information about a specific batch-processing job.
|
604
|
+
# Gets information about a batch-processing job with a specified ID.
|
605
|
+
# @param batch_id [String] The ID of the batch-processing job whose information you want to retrieve.
|
603
606
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
604
|
-
def
|
607
|
+
def get_batch(batch_id:)
|
608
|
+
raise ArgumentError.new("batch_id must be provided") if batch_id.nil?
|
609
|
+
|
605
610
|
headers = {
|
606
611
|
}
|
607
|
-
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "
|
612
|
+
sdk_headers = Common.new.get_sdk_headers("compare-comply", "V1", "get_batch")
|
608
613
|
headers.merge!(sdk_headers)
|
609
614
|
|
610
615
|
params = {
|
611
616
|
"version" => @version
|
612
617
|
}
|
613
618
|
|
614
|
-
method_url = "/v1/batches"
|
619
|
+
method_url = "/v1/batches/%s" % [ERB::Util.url_encode(batch_id)]
|
615
620
|
|
616
621
|
response = request(
|
617
622
|
method: "GET",
|