ibm_watson 1.4.0 → 2.0.1
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 +43 -6
- data/lib/ibm_watson/assistant_v1.rb +213 -195
- data/lib/ibm_watson/assistant_v2.rb +221 -20
- data/lib/ibm_watson/compare_comply_v1.rb +35 -21
- data/lib/ibm_watson/discovery_v1.rb +132 -13
- data/lib/ibm_watson/discovery_v2.rb +734 -21
- data/lib/ibm_watson/language_translator_v3.rb +205 -67
- data/lib/ibm_watson/natural_language_classifier_v1.rb +4 -2
- data/lib/ibm_watson/natural_language_understanding_v1.rb +21 -21
- data/lib/ibm_watson/personality_insights_v3.rb +27 -18
- data/lib/ibm_watson/speech_to_text_v1.rb +65 -53
- data/lib/ibm_watson/text_to_speech_v1.rb +124 -140
- data/lib/ibm_watson/tone_analyzer_v3.rb +12 -13
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +33 -16
- data/lib/ibm_watson/visual_recognition_v4.rb +103 -17
- data/test/integration/test_assistant_v1.rb +9 -0
- data/test/integration/test_assistant_v2.rb +34 -0
- data/test/integration/test_discovery_v2.rb +132 -6
- data/test/integration/test_language_translator_v3.rb +5 -0
- data/test/integration/test_text_to_speech_v1.rb +3 -3
- data/test/integration/test_visual_recognition_v4.rb +9 -0
- data/test/unit/test_assistant_v1.rb +150 -99
- data/test/unit/test_assistant_v2.rb +153 -8
- data/test/unit/test_compare_comply_v1.rb +20 -20
- data/test/unit/test_discovery_v1.rb +125 -125
- data/test/unit/test_discovery_v2.rb +262 -29
- data/test/unit/test_language_translator_v3.rb +85 -24
- data/test/unit/test_natural_language_classifier_v1.rb +17 -17
- data/test/unit/test_natural_language_understanding_v1.rb +10 -10
- data/test/unit/test_personality_insights_v3.rb +14 -14
- data/test/unit/test_speech_to_text_v1.rb +97 -97
- data/test/unit/test_text_to_speech_v1.rb +48 -48
- data/test/unit/test_tone_analyzer_v3.rb +12 -12
- data/test/unit/test_visual_recognition_v3.rb +16 -16
- data/test/unit/test_visual_recognition_v4.rb +56 -38
- metadata +8 -7
@@ -13,9 +13,11 @@
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
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.19.0-be3b4618-20201113-200858
|
18
|
+
#
|
17
19
|
# IBM Watson™ Language Translator translates text from one language to another.
|
18
|
-
# The service offers multiple IBM
|
20
|
+
# The service offers multiple IBM-provided translation models that you can customize based
|
19
21
|
# on your unique terminology and language. Use Language Translator to take news from
|
20
22
|
# across the globe and present it in your language, communicate with your customers in
|
21
23
|
# their own language, and more.
|
@@ -33,22 +35,15 @@ module IBMWatson
|
|
33
35
|
class LanguageTranslatorV3 < IBMCloudSdkCore::BaseService
|
34
36
|
include Concurrent::Async
|
35
37
|
DEFAULT_SERVICE_NAME = "language_translator"
|
36
|
-
DEFAULT_SERVICE_URL = "https://
|
38
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.language-translator.watson.cloud.ibm.com"
|
39
|
+
attr_accessor :version
|
37
40
|
##
|
38
41
|
# @!method initialize(args)
|
39
42
|
# Construct a new client for the Language Translator service.
|
40
43
|
#
|
41
44
|
# @param args [Hash] The args to initialize with
|
42
|
-
# @option args version [String]
|
43
|
-
#
|
44
|
-
# incompatible way, a new minor version of the API is released.
|
45
|
-
# The service uses the API version for the date you specify, or
|
46
|
-
# the most recent version before that date. Note that you should
|
47
|
-
# not programmatically specify the current date at runtime, in
|
48
|
-
# case the API has been updated since your application's release.
|
49
|
-
# Instead, specify a version date that is compatible with your
|
50
|
-
# application, and don't change it until your application is
|
51
|
-
# ready for a later version.
|
45
|
+
# @option args version [String] Release date of the version of the API you want to use. Specify dates in
|
46
|
+
# YYYY-MM-DD format. The current version is `2018-05-01`.
|
52
47
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
53
48
|
# The base service_url may differ between IBM Cloud regions.
|
54
49
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
@@ -57,10 +52,10 @@ module IBMWatson
|
|
57
52
|
def initialize(args = {})
|
58
53
|
@__async_initialized__ = false
|
59
54
|
defaults = {}
|
60
|
-
defaults[:version] = nil
|
61
55
|
defaults[:service_url] = DEFAULT_SERVICE_URL
|
62
56
|
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
63
57
|
defaults[:authenticator] = nil
|
58
|
+
defaults[:version] = nil
|
64
59
|
user_service_url = args[:service_url] unless args[:service_url].nil?
|
65
60
|
args = defaults.merge(args)
|
66
61
|
@version = args[:version]
|
@@ -71,6 +66,43 @@ module IBMWatson
|
|
71
66
|
@service_url = user_service_url unless user_service_url.nil?
|
72
67
|
end
|
73
68
|
|
69
|
+
#########################
|
70
|
+
# Languages
|
71
|
+
#########################
|
72
|
+
|
73
|
+
##
|
74
|
+
# @!method list_languages
|
75
|
+
# List supported languages.
|
76
|
+
# Lists all supported languages for translation. The method returns an array of
|
77
|
+
# supported languages with information about each language. Languages are listed in
|
78
|
+
# alphabetical order by language code (for example, `af`, `ar`). In addition to
|
79
|
+
# basic information about each language, the response indicates whether the language
|
80
|
+
# is `supported_as_source` for translation and `supported_as_target` for
|
81
|
+
# translation. It also lists whether the language is `identifiable`.
|
82
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
83
|
+
def list_languages
|
84
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
85
|
+
|
86
|
+
headers = {
|
87
|
+
}
|
88
|
+
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_languages")
|
89
|
+
headers.merge!(sdk_headers)
|
90
|
+
|
91
|
+
params = {
|
92
|
+
"version" => @version
|
93
|
+
}
|
94
|
+
|
95
|
+
method_url = "/v3/languages"
|
96
|
+
|
97
|
+
response = request(
|
98
|
+
method: "GET",
|
99
|
+
url: method_url,
|
100
|
+
headers: headers,
|
101
|
+
params: params,
|
102
|
+
accept_json: true
|
103
|
+
)
|
104
|
+
response
|
105
|
+
end
|
74
106
|
#########################
|
75
107
|
# Translation
|
76
108
|
#########################
|
@@ -78,20 +110,31 @@ module IBMWatson
|
|
78
110
|
##
|
79
111
|
# @!method translate(text:, model_id: nil, source: nil, target: nil)
|
80
112
|
# Translate.
|
81
|
-
# Translates the input text from the source language to the target language.
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
# @param
|
113
|
+
# Translates the input text from the source language to the target language. Specify
|
114
|
+
# a model ID that indicates the source and target languages, or specify the source
|
115
|
+
# and target languages individually. You can omit the source language to have the
|
116
|
+
# service attempt to detect the language from the input text. If you omit the source
|
117
|
+
# language, the request must contain sufficient input text for the service to
|
118
|
+
# identify the source language.
|
119
|
+
#
|
120
|
+
# You can translate a maximum of 50 KB (51,200 bytes) of text with a single request.
|
121
|
+
# All input text must be encoded in UTF-8 format.
|
122
|
+
# @param text [Array[String]] Input text in UTF-8 encoding. Submit a maximum of 50 KB (51,200 bytes) of text
|
123
|
+
# with a single request. Multiple elements result in multiple translations in the
|
124
|
+
# response.
|
125
|
+
# @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
|
126
|
+
# base model for English-to-German translation. A model ID overrides the `source`
|
127
|
+
# and `target` parameters and is required if you use a custom model. If no model ID
|
128
|
+
# is specified, you must specify at least a target language.
|
129
|
+
# @param source [String] Language code that specifies the language of the input text. If omitted, the
|
130
|
+
# service derives the source language from the input text. The input must contain
|
131
|
+
# sufficient text for the service to identify the language reliably.
|
91
132
|
# @param target [String] Language code that specifies the target language for translation. Required if
|
92
133
|
# model ID is not specified.
|
93
134
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
94
135
|
def translate(text:, model_id: nil, source: nil, target: nil)
|
136
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
137
|
+
|
95
138
|
raise ArgumentError.new("text must be provided") if text.nil?
|
96
139
|
|
97
140
|
headers = {
|
@@ -133,6 +176,8 @@ module IBMWatson
|
|
133
176
|
# example, `en` for English or `es` for Spanish) and name of each language.
|
134
177
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
135
178
|
def list_identifiable_languages
|
179
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
180
|
+
|
136
181
|
headers = {
|
137
182
|
}
|
138
183
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_identifiable_languages")
|
@@ -161,6 +206,8 @@ module IBMWatson
|
|
161
206
|
# @param text [String] Input text in UTF-8 format.
|
162
207
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
163
208
|
def identify(text:)
|
209
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
210
|
+
|
164
211
|
raise ArgumentError.new("text must be provided") if text.nil?
|
165
212
|
|
166
213
|
headers = {
|
@@ -197,12 +244,15 @@ module IBMWatson
|
|
197
244
|
# Lists available translation models.
|
198
245
|
# @param source [String] Specify a language code to filter results by source language.
|
199
246
|
# @param target [String] Specify a language code to filter results by target language.
|
200
|
-
# @param default [Boolean] If the default parameter isn't specified, the service
|
247
|
+
# @param default [Boolean] If the `default` parameter isn't specified, the service returns all models
|
201
248
|
# (default and non-default) for each language pair. To return only default models,
|
202
|
-
# set this to `true`. To return only non-default models, set this
|
203
|
-
# is exactly one default model
|
249
|
+
# set this parameter to `true`. To return only non-default models, set this
|
250
|
+
# parameter to `false`. There is exactly one default model, the IBM-provided base
|
251
|
+
# model, per language pair.
|
204
252
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
205
253
|
def list_models(source: nil, target: nil, default: nil)
|
254
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
255
|
+
|
206
256
|
headers = {
|
207
257
|
}
|
208
258
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_models")
|
@@ -230,38 +280,109 @@ module IBMWatson
|
|
230
280
|
##
|
231
281
|
# @!method create_model(base_model_id:, forced_glossary: nil, parallel_corpus: nil, name: nil)
|
232
282
|
# Create model.
|
233
|
-
# Uploads
|
283
|
+
# Uploads training files to customize a translation model. You can customize a model
|
284
|
+
# with a forced glossary or with a parallel corpus:
|
285
|
+
# * Use a *forced glossary* to force certain terms and phrases to be translated in a
|
286
|
+
# specific way. You can upload only a single forced glossary file for a model. The
|
287
|
+
# size of a forced glossary file for a custom model is limited to 10 MB.
|
288
|
+
# * Use a *parallel corpus* when you want your custom model to learn from general
|
289
|
+
# translation patterns in parallel sentences in your samples. What your model learns
|
290
|
+
# from a parallel corpus can improve translation results for input text that the
|
291
|
+
# model has not been trained on. You can upload multiple parallel corpora files with
|
292
|
+
# a request. To successfully train with parallel corpora, the corpora files must
|
293
|
+
# contain a cumulative total of at least 5000 parallel sentences. The cumulative
|
294
|
+
# size of all uploaded corpus files for a custom model is limited to 250 MB.
|
295
|
+
#
|
296
|
+
# Depending on the type of customization and the size of the uploaded files,
|
297
|
+
# training time can range from minutes for a glossary to several hours for a large
|
298
|
+
# parallel corpus. To create a model that is customized with a parallel corpus and a
|
299
|
+
# forced glossary, customize the model with a parallel corpus first and then
|
300
|
+
# customize the resulting model with a forced glossary.
|
301
|
+
#
|
302
|
+
# You can create a maximum of 10 custom models per language pair. For more
|
303
|
+
# information about customizing a translation model, including the formatting and
|
304
|
+
# character restrictions for data files, see [Customizing your
|
305
|
+
# model](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing).
|
306
|
+
#
|
307
|
+
#
|
308
|
+
# #### Supported file formats
|
309
|
+
#
|
310
|
+
# You can provide your training data for customization in the following document
|
311
|
+
# formats:
|
312
|
+
# * **TMX** (`.tmx`) - Translation Memory eXchange (TMX) is an XML specification for
|
313
|
+
# the exchange of translation memories.
|
314
|
+
# * **XLIFF** (`.xliff`) - XML Localization Interchange File Format (XLIFF) is an
|
315
|
+
# XML specification for the exchange of translation memories.
|
316
|
+
# * **CSV** (`.csv`) - Comma-separated values (CSV) file with two columns for
|
317
|
+
# aligned sentences and phrases. The first row must have two language codes. The
|
318
|
+
# first column is for the source language code, and the second column is for the
|
319
|
+
# target language code.
|
320
|
+
# * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file with two columns
|
321
|
+
# for aligned sentences and phrases. The first row must have two language codes. The
|
322
|
+
# first column is for the source language code, and the second column is for the
|
323
|
+
# target language code.
|
324
|
+
# * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and
|
325
|
+
# phrases.
|
326
|
+
# * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns
|
327
|
+
# for aligned sentences and phrases. The first row contains the language code.
|
328
|
+
#
|
329
|
+
# You must encode all text data in UTF-8 format. For more information, see
|
330
|
+
# [Supported document formats for training
|
331
|
+
# data](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing#supported-document-formats-for-training-data).
|
332
|
+
#
|
333
|
+
#
|
334
|
+
# #### Specifying file formats
|
335
|
+
#
|
336
|
+
# You can indicate the format of a file by including the file extension with the
|
337
|
+
# file name. Use the file extensions shown in **Supported file formats**.
|
338
|
+
#
|
339
|
+
# Alternatively, you can omit the file extension and specify one of the following
|
340
|
+
# `content-type` specifications for the file:
|
341
|
+
# * **TMX** - `application/x-tmx+xml`
|
342
|
+
# * **XLIFF** - `application/xliff+xml`
|
343
|
+
# * **CSV** - `text/csv`
|
344
|
+
# * **TSV** - `text/tab-separated-values`
|
345
|
+
# * **JSON** - `application/json`
|
346
|
+
# * **Microsoft Excel** -
|
347
|
+
# `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
|
234
348
|
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
# corpus <b>and</b> a forced glossary, proceed in two steps: customize with a
|
238
|
-
# parallel corpus first and then customize the resulting model with a glossary.
|
239
|
-
# Depending on the type of customization and the size of the uploaded corpora,
|
240
|
-
# training can range from minutes for a glossary to several hours for a large
|
241
|
-
# parallel corpus. You can upload a single forced glossary file and this file must
|
242
|
-
# be less than <b>10 MB</b>. You can upload multiple parallel corpora tmx files. The
|
243
|
-
# cumulative file size of all uploaded files is limited to <b>250 MB</b>. To
|
244
|
-
# successfully train with a parallel corpus you must have at least <b>5,000 parallel
|
245
|
-
# sentences</b> in your corpus.
|
349
|
+
# For example, with `curl`, use the following `content-type` specification to
|
350
|
+
# indicate the format of a CSV file named **glossary**:
|
246
351
|
#
|
247
|
-
#
|
248
|
-
# @param base_model_id [String] The
|
249
|
-
# models, use the `List models` method.
|
250
|
-
# customizable. In addition, all
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
#
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
352
|
+
# `--form "forced_glossary=@glossary;type=text/csv"`.
|
353
|
+
# @param base_model_id [String] The ID of the translation model to use as the base for customization. To see
|
354
|
+
# available models and IDs, use the `List models` method. Most models that are
|
355
|
+
# provided with the service are customizable. In addition, all models that you
|
356
|
+
# create with parallel corpora customization can be further customized with a forced
|
357
|
+
# glossary.
|
358
|
+
# @param forced_glossary [File] A file with forced glossary terms for the source and target languages. The
|
359
|
+
# customizations in the file completely overwrite the domain translation data,
|
360
|
+
# including high frequency or high confidence phrase translations.
|
361
|
+
#
|
362
|
+
# You can upload only one glossary file for a custom model, and the glossary can
|
363
|
+
# have a maximum size of 10 MB. A forced glossary must contain single words or short
|
364
|
+
# phrases. For more information, see **Supported file formats** in the method
|
365
|
+
# description.
|
366
|
+
#
|
367
|
+
# *With `curl`, use `--form forced_glossary=@{filename}`.*.
|
368
|
+
# @param parallel_corpus [File] A file with parallel sentences for the source and target languages. You can upload
|
369
|
+
# multiple parallel corpus files in one request by repeating the parameter. All
|
370
|
+
# uploaded parallel corpus files combined must contain at least 5000 parallel
|
371
|
+
# sentences to train successfully. You can provide a maximum of 500,000 parallel
|
372
|
+
# sentences across all corpora.
|
373
|
+
#
|
374
|
+
# A single entry in a corpus file can contain a maximum of 80 words. All corpora
|
375
|
+
# files for a custom model can have a cumulative maximum size of 250 MB. For more
|
376
|
+
# information, see **Supported file formats** in the method description.
|
377
|
+
#
|
378
|
+
# *With `curl`, use `--form parallel_corpus=@{filename}`.*.
|
260
379
|
# @param name [String] An optional model name that you can use to identify the model. Valid characters
|
261
|
-
# are letters, numbers, dashes, underscores, spaces and apostrophes. The maximum
|
262
|
-
# length is 32 characters.
|
380
|
+
# are letters, numbers, dashes, underscores, spaces, and apostrophes. The maximum
|
381
|
+
# length of the name is 32 characters.
|
263
382
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
264
383
|
def create_model(base_model_id:, forced_glossary: nil, parallel_corpus: nil, name: nil)
|
384
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
385
|
+
|
265
386
|
raise ArgumentError.new("base_model_id must be provided") if base_model_id.nil?
|
266
387
|
|
267
388
|
headers = {
|
@@ -311,6 +432,8 @@ module IBMWatson
|
|
311
432
|
# @param model_id [String] Model ID of the model to delete.
|
312
433
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
313
434
|
def delete_model(model_id:)
|
435
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
436
|
+
|
314
437
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
315
438
|
|
316
439
|
headers = {
|
@@ -339,10 +462,12 @@ module IBMWatson
|
|
339
462
|
# Get model details.
|
340
463
|
# Gets information about a translation model, including training status for custom
|
341
464
|
# models. Use this API call to poll the status of your customization request. A
|
342
|
-
# successfully completed training
|
465
|
+
# successfully completed training has a status of `available`.
|
343
466
|
# @param model_id [String] Model ID of the model to get.
|
344
467
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
345
468
|
def get_model(model_id:)
|
469
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
470
|
+
|
346
471
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
347
472
|
|
348
473
|
headers = {
|
@@ -375,6 +500,8 @@ module IBMWatson
|
|
375
500
|
# Lists documents that have been submitted for translation.
|
376
501
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
377
502
|
def list_documents
|
503
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
504
|
+
|
378
505
|
headers = {
|
379
506
|
}
|
380
507
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_documents")
|
@@ -401,26 +528,31 @@ module IBMWatson
|
|
401
528
|
# Translate document.
|
402
529
|
# Submit a document for translation. You can submit the document contents in the
|
403
530
|
# `file` parameter, or you can reference a previously submitted document by document
|
404
|
-
# ID.
|
405
|
-
#
|
406
|
-
#
|
407
|
-
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
531
|
+
# ID. The maximum file size for document translation is
|
532
|
+
# * 20 MB for service instances on the Standard, Advanced, and Premium plans
|
533
|
+
# * 2 MB for service instances on the Lite plan.
|
534
|
+
# @param file [File] The contents of the source file to translate. The maximum file size for document
|
535
|
+
# translation is 20 MB for service instances on the Standard, Advanced, and Premium
|
536
|
+
# plans, and 2 MB for service instances on the Lite plan. For more information, see
|
537
|
+
# [Supported file formats
|
538
|
+
# (Beta)](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats).
|
411
539
|
# @param filename [String] The filename for file.
|
412
540
|
# @param file_content_type [String] The content type of file.
|
413
|
-
# @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM
|
414
|
-
# base model for English
|
415
|
-
# target parameters and is required if you use a custom model. If no model ID
|
416
|
-
# specified, you must specify a target language.
|
417
|
-
# @param source [String] Language code that specifies the language of the source document.
|
541
|
+
# @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
|
542
|
+
# base model for English-to-German translation. A model ID overrides the `source`
|
543
|
+
# and `target` parameters and is required if you use a custom model. If no model ID
|
544
|
+
# is specified, you must specify at least a target language.
|
545
|
+
# @param source [String] Language code that specifies the language of the source document. If omitted, the
|
546
|
+
# service derives the source language from the input text. The input must contain
|
547
|
+
# sufficient text for the service to identify the language reliably.
|
418
548
|
# @param target [String] Language code that specifies the target language for translation. Required if
|
419
549
|
# model ID is not specified.
|
420
550
|
# @param document_id [String] To use a previously submitted document as the source for a new translation, enter
|
421
551
|
# the `document_id` of the document.
|
422
552
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
423
553
|
def translate_document(file:, filename: nil, file_content_type: nil, model_id: nil, source: nil, target: nil, document_id: nil)
|
554
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
555
|
+
|
424
556
|
raise ArgumentError.new("file must be provided") if file.nil?
|
425
557
|
|
426
558
|
headers = {
|
@@ -468,6 +600,8 @@ module IBMWatson
|
|
468
600
|
# @param document_id [String] The document ID of the document.
|
469
601
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
470
602
|
def get_document_status(document_id:)
|
603
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
604
|
+
|
471
605
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
472
606
|
|
473
607
|
headers = {
|
@@ -498,6 +632,8 @@ module IBMWatson
|
|
498
632
|
# @param document_id [String] Document ID of the document to delete.
|
499
633
|
# @return [nil]
|
500
634
|
def delete_document(document_id:)
|
635
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
636
|
+
|
501
637
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
502
638
|
|
503
639
|
headers = {
|
@@ -541,6 +677,8 @@ module IBMWatson
|
|
541
677
|
# example, 'text/html;charset=utf-8'.
|
542
678
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
543
679
|
def get_translated_document(document_id:, accept: nil)
|
680
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
681
|
+
|
544
682
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
545
683
|
|
546
684
|
headers = {
|
@@ -13,7 +13,9 @@
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
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.19.0-be3b4618-20201113-200858
|
18
|
+
#
|
17
19
|
# IBM Watson™ Natural Language Classifier uses machine learning algorithms to
|
18
20
|
# return the top matching predefined classes for short text input. You create and train a
|
19
21
|
# classifier to connect predefined classes to example texts so that the service can apply
|
@@ -32,7 +34,7 @@ module IBMWatson
|
|
32
34
|
class NaturalLanguageClassifierV1 < IBMCloudSdkCore::BaseService
|
33
35
|
include Concurrent::Async
|
34
36
|
DEFAULT_SERVICE_NAME = "natural_language_classifier"
|
35
|
-
DEFAULT_SERVICE_URL = "https://
|
37
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
36
38
|
##
|
37
39
|
# @!method initialize(args)
|
38
40
|
# Construct a new client for the Natural Language Classifier service.
|
@@ -13,7 +13,9 @@
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
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.19.0-be3b4618-20201113-200858
|
18
|
+
#
|
17
19
|
# Analyze various features of text content at scale. Provide text, raw HTML, or a public
|
18
20
|
# URL and IBM Watson Natural Language Understanding will give you results for the features
|
19
21
|
# you request. The service cleans HTML content before analysis by default, so the results
|
@@ -37,22 +39,15 @@ module IBMWatson
|
|
37
39
|
class NaturalLanguageUnderstandingV1 < IBMCloudSdkCore::BaseService
|
38
40
|
include Concurrent::Async
|
39
41
|
DEFAULT_SERVICE_NAME = "natural_language_understanding"
|
40
|
-
DEFAULT_SERVICE_URL = "https://
|
42
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
43
|
+
attr_accessor :version
|
41
44
|
##
|
42
45
|
# @!method initialize(args)
|
43
46
|
# Construct a new client for the Natural Language Understanding service.
|
44
47
|
#
|
45
48
|
# @param args [Hash] The args to initialize with
|
46
|
-
# @option args version [String]
|
47
|
-
#
|
48
|
-
# incompatible way, a new minor version of the API is released.
|
49
|
-
# The service uses the API version for the date you specify, or
|
50
|
-
# the most recent version before that date. Note that you should
|
51
|
-
# not programmatically specify the current date at runtime, in
|
52
|
-
# case the API has been updated since your application's release.
|
53
|
-
# Instead, specify a version date that is compatible with your
|
54
|
-
# application, and don't change it until your application is
|
55
|
-
# ready for a later version.
|
49
|
+
# @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 `2020-08-01`.
|
56
51
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
57
52
|
# The base service_url may differ between IBM Cloud regions.
|
58
53
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
@@ -61,10 +56,10 @@ module IBMWatson
|
|
61
56
|
def initialize(args = {})
|
62
57
|
@__async_initialized__ = false
|
63
58
|
defaults = {}
|
64
|
-
defaults[:version] = nil
|
65
59
|
defaults[:service_url] = DEFAULT_SERVICE_URL
|
66
60
|
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
67
61
|
defaults[:authenticator] = nil
|
62
|
+
defaults[:version] = nil
|
68
63
|
user_service_url = args[:service_url] unless args[:service_url].nil?
|
69
64
|
args = defaults.merge(args)
|
70
65
|
@version = args[:version]
|
@@ -92,7 +87,8 @@ module IBMWatson
|
|
92
87
|
# - Relations
|
93
88
|
# - Semantic roles
|
94
89
|
# - Sentiment
|
95
|
-
# - Syntax
|
90
|
+
# - Syntax
|
91
|
+
# - Summarization (Experimental)
|
96
92
|
#
|
97
93
|
# If a language for the input text is not specified with the `language` parameter,
|
98
94
|
# the service [automatically detects the
|
@@ -104,10 +100,9 @@ module IBMWatson
|
|
104
100
|
# required.
|
105
101
|
# @param url [String] The webpage to analyze. One of the `text`, `html`, or `url` parameters is
|
106
102
|
# required.
|
107
|
-
# @param clean [Boolean] Set this to `false` to disable webpage cleaning.
|
108
|
-
# cleaning, see
|
109
|
-
# webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages)
|
110
|
-
# documentation.
|
103
|
+
# @param clean [Boolean] Set this to `false` to disable webpage cleaning. For more information about
|
104
|
+
# webpage cleaning, see [Analyzing
|
105
|
+
# webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages).
|
111
106
|
# @param xpath [String] An [XPath
|
112
107
|
# query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath)
|
113
108
|
# to perform on `html` or `url` input. Results of the query will be appended to the
|
@@ -117,12 +112,13 @@ module IBMWatson
|
|
117
112
|
# @param return_analyzed_text [Boolean] Whether or not to return the analyzed text.
|
118
113
|
# @param language [String] ISO 639-1 code that specifies the language of your text. This overrides automatic
|
119
114
|
# language detection. Language support differs depending on the features you include
|
120
|
-
# in your analysis.
|
121
|
-
# support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support)
|
122
|
-
# for more information.
|
115
|
+
# in your analysis. For more information, see [Language
|
116
|
+
# support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support).
|
123
117
|
# @param limit_text_characters [Fixnum] Sets the maximum number of characters that are processed by the service.
|
124
118
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
125
119
|
def analyze(features:, text: nil, html: nil, url: nil, clean: nil, xpath: nil, fallback_to_raw: nil, return_analyzed_text: nil, language: nil, limit_text_characters: nil)
|
120
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
121
|
+
|
126
122
|
raise ArgumentError.new("features must be provided") if features.nil?
|
127
123
|
|
128
124
|
headers = {
|
@@ -171,6 +167,8 @@ module IBMWatson
|
|
171
167
|
# that are deployed to your Natural Language Understanding service.
|
172
168
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
173
169
|
def list_models
|
170
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
171
|
+
|
174
172
|
headers = {
|
175
173
|
}
|
176
174
|
sdk_headers = Common.new.get_sdk_headers("natural-language-understanding", "V1", "list_models")
|
@@ -199,6 +197,8 @@ module IBMWatson
|
|
199
197
|
# @param model_id [String] Model ID of the model to delete.
|
200
198
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
201
199
|
def delete_model(model_id:)
|
200
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
201
|
+
|
202
202
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
203
203
|
|
204
204
|
headers = {
|