ibm_watson 1.3.1 → 2.0.0
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 +36 -5
- data/lib/ibm_watson/assistant_v1.rb +225 -199
- data/lib/ibm_watson/assistant_v2.rb +228 -21
- data/lib/ibm_watson/compare_comply_v1.rb +43 -24
- data/lib/ibm_watson/discovery_v1.rb +144 -19
- data/lib/ibm_watson/discovery_v2.rb +742 -23
- data/lib/ibm_watson/language_translator_v3.rb +216 -64
- data/lib/ibm_watson/natural_language_classifier_v1.rb +11 -3
- data/lib/ibm_watson/natural_language_understanding_v1.rb +32 -26
- data/lib/ibm_watson/personality_insights_v3.rb +34 -19
- data/lib/ibm_watson/speech_to_text_v1.rb +239 -106
- data/lib/ibm_watson/text_to_speech_v1.rb +139 -146
- data/lib/ibm_watson/tone_analyzer_v3.rb +19 -14
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +40 -17
- data/lib/ibm_watson/visual_recognition_v4.rb +110 -18
- data/test/integration/test_assistant_v1.rb +9 -0
- data/test/integration/test_assistant_v2.rb +34 -0
- data/test/integration/test_compare_comply_v1.rb +1 -12
- 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 +149 -98
- 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 +3 -3
@@ -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.
|
@@ -32,39 +34,75 @@ module IBMWatson
|
|
32
34
|
# The Language Translator V3 service.
|
33
35
|
class LanguageTranslatorV3 < IBMCloudSdkCore::BaseService
|
34
36
|
include Concurrent::Async
|
37
|
+
DEFAULT_SERVICE_NAME = "language_translator"
|
38
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.language-translator.watson.cloud.ibm.com"
|
39
|
+
attr_accessor :version
|
35
40
|
##
|
36
41
|
# @!method initialize(args)
|
37
42
|
# Construct a new client for the Language Translator service.
|
38
43
|
#
|
39
44
|
# @param args [Hash] The args to initialize with
|
40
|
-
# @option args version [String]
|
41
|
-
#
|
42
|
-
# incompatible way, a new minor version of the API is released.
|
43
|
-
# The service uses the API version for the date you specify, or
|
44
|
-
# the most recent version before that date. Note that you should
|
45
|
-
# not programmatically specify the current date at runtime, in
|
46
|
-
# case the API has been updated since your application's release.
|
47
|
-
# Instead, specify a version date that is compatible with your
|
48
|
-
# application, and don't change it until your application is
|
49
|
-
# 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`.
|
50
47
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
51
48
|
# The base service_url may differ between IBM Cloud regions.
|
52
49
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
50
|
+
# @option args service_name [String] The name of the service to configure. Will be used as the key to load
|
51
|
+
# any external configuration, if applicable.
|
53
52
|
def initialize(args = {})
|
54
53
|
@__async_initialized__ = false
|
55
54
|
defaults = {}
|
56
|
-
defaults[:
|
57
|
-
defaults[:
|
55
|
+
defaults[:service_url] = DEFAULT_SERVICE_URL
|
56
|
+
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
58
57
|
defaults[:authenticator] = nil
|
58
|
+
defaults[:version] = nil
|
59
|
+
user_service_url = args[:service_url] unless args[:service_url].nil?
|
59
60
|
args = defaults.merge(args)
|
60
61
|
@version = args[:version]
|
61
62
|
raise ArgumentError.new("version must be provided") if @version.nil?
|
62
63
|
|
63
|
-
args[:service_name] = "language_translator"
|
64
64
|
args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
|
65
65
|
super
|
66
|
+
@service_url = user_service_url unless user_service_url.nil?
|
66
67
|
end
|
67
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
|
68
106
|
#########################
|
69
107
|
# Translation
|
70
108
|
#########################
|
@@ -72,15 +110,31 @@ module IBMWatson
|
|
72
110
|
##
|
73
111
|
# @!method translate(text:, model_id: nil, source: nil, target: nil)
|
74
112
|
# Translate.
|
75
|
-
# Translates the input text from the source language to the target language.
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
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.
|
132
|
+
# @param target [String] Language code that specifies the target language for translation. Required if
|
133
|
+
# model ID is not specified.
|
82
134
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
83
135
|
def translate(text:, model_id: nil, source: nil, target: nil)
|
136
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
137
|
+
|
84
138
|
raise ArgumentError.new("text must be provided") if text.nil?
|
85
139
|
|
86
140
|
headers = {
|
@@ -122,6 +176,8 @@ module IBMWatson
|
|
122
176
|
# example, `en` for English or `es` for Spanish) and name of each language.
|
123
177
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
124
178
|
def list_identifiable_languages
|
179
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
180
|
+
|
125
181
|
headers = {
|
126
182
|
}
|
127
183
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_identifiable_languages")
|
@@ -150,6 +206,8 @@ module IBMWatson
|
|
150
206
|
# @param text [String] Input text in UTF-8 format.
|
151
207
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
152
208
|
def identify(text:)
|
209
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
210
|
+
|
153
211
|
raise ArgumentError.new("text must be provided") if text.nil?
|
154
212
|
|
155
213
|
headers = {
|
@@ -186,12 +244,15 @@ module IBMWatson
|
|
186
244
|
# Lists available translation models.
|
187
245
|
# @param source [String] Specify a language code to filter results by source language.
|
188
246
|
# @param target [String] Specify a language code to filter results by target language.
|
189
|
-
# @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
|
190
248
|
# (default and non-default) for each language pair. To return only default models,
|
191
|
-
# set this to `true`. To return only non-default models, set this
|
192
|
-
# 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.
|
193
252
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
194
253
|
def list_models(source: nil, target: nil, default: nil)
|
254
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
255
|
+
|
195
256
|
headers = {
|
196
257
|
}
|
197
258
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_models")
|
@@ -219,38 +280,109 @@ module IBMWatson
|
|
219
280
|
##
|
220
281
|
# @!method create_model(base_model_id:, forced_glossary: nil, parallel_corpus: nil, name: nil)
|
221
282
|
# Create model.
|
222
|
-
# 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`
|
223
348
|
#
|
224
|
-
#
|
225
|
-
#
|
226
|
-
# corpus <b>and</b> a forced glossary, proceed in two steps: customize with a
|
227
|
-
# parallel corpus first and then customize the resulting model with a glossary.
|
228
|
-
# Depending on the type of customization and the size of the uploaded corpora,
|
229
|
-
# training can range from minutes for a glossary to several hours for a large
|
230
|
-
# parallel corpus. You can upload a single forced glossary file and this file must
|
231
|
-
# be less than <b>10 MB</b>. You can upload multiple parallel corpora tmx files. The
|
232
|
-
# cumulative file size of all uploaded files is limited to <b>250 MB</b>. To
|
233
|
-
# successfully train with a parallel corpus you must have at least <b>5,000 parallel
|
234
|
-
# 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**:
|
235
351
|
#
|
236
|
-
#
|
237
|
-
# @param base_model_id [String] The
|
238
|
-
# models, use the `List models` method.
|
239
|
-
# customizable. In addition, all
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
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}`.*.
|
249
379
|
# @param name [String] An optional model name that you can use to identify the model. Valid characters
|
250
|
-
# are letters, numbers, dashes, underscores, spaces and apostrophes. The maximum
|
251
|
-
# length is 32 characters.
|
380
|
+
# are letters, numbers, dashes, underscores, spaces, and apostrophes. The maximum
|
381
|
+
# length of the name is 32 characters.
|
252
382
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
253
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
|
+
|
254
386
|
raise ArgumentError.new("base_model_id must be provided") if base_model_id.nil?
|
255
387
|
|
256
388
|
headers = {
|
@@ -300,6 +432,8 @@ module IBMWatson
|
|
300
432
|
# @param model_id [String] Model ID of the model to delete.
|
301
433
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
302
434
|
def delete_model(model_id:)
|
435
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
436
|
+
|
303
437
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
304
438
|
|
305
439
|
headers = {
|
@@ -328,10 +462,12 @@ module IBMWatson
|
|
328
462
|
# Get model details.
|
329
463
|
# Gets information about a translation model, including training status for custom
|
330
464
|
# models. Use this API call to poll the status of your customization request. A
|
331
|
-
# successfully completed training
|
465
|
+
# successfully completed training has a status of `available`.
|
332
466
|
# @param model_id [String] Model ID of the model to get.
|
333
467
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
334
468
|
def get_model(model_id:)
|
469
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
470
|
+
|
335
471
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
336
472
|
|
337
473
|
headers = {
|
@@ -364,6 +500,8 @@ module IBMWatson
|
|
364
500
|
# Lists documents that have been submitted for translation.
|
365
501
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
366
502
|
def list_documents
|
503
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
504
|
+
|
367
505
|
headers = {
|
368
506
|
}
|
369
507
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_documents")
|
@@ -390,23 +528,31 @@ module IBMWatson
|
|
390
528
|
# Translate document.
|
391
529
|
# Submit a document for translation. You can submit the document contents in the
|
392
530
|
# `file` parameter, or you can reference a previously submitted document by document
|
393
|
-
# ID.
|
394
|
-
#
|
395
|
-
#
|
396
|
-
#
|
397
|
-
#
|
398
|
-
#
|
399
|
-
#
|
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).
|
400
539
|
# @param filename [String] The filename for file.
|
401
540
|
# @param file_content_type [String] The content type of file.
|
402
|
-
# @param model_id [String] The model to use for translation.
|
403
|
-
#
|
404
|
-
#
|
405
|
-
#
|
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.
|
548
|
+
# @param target [String] Language code that specifies the target language for translation. Required if
|
549
|
+
# model ID is not specified.
|
406
550
|
# @param document_id [String] To use a previously submitted document as the source for a new translation, enter
|
407
551
|
# the `document_id` of the document.
|
408
552
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
409
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
|
+
|
410
556
|
raise ArgumentError.new("file must be provided") if file.nil?
|
411
557
|
|
412
558
|
headers = {
|
@@ -454,6 +600,8 @@ module IBMWatson
|
|
454
600
|
# @param document_id [String] The document ID of the document.
|
455
601
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
456
602
|
def get_document_status(document_id:)
|
603
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
604
|
+
|
457
605
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
458
606
|
|
459
607
|
headers = {
|
@@ -484,6 +632,8 @@ module IBMWatson
|
|
484
632
|
# @param document_id [String] Document ID of the document to delete.
|
485
633
|
# @return [nil]
|
486
634
|
def delete_document(document_id:)
|
635
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
636
|
+
|
487
637
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
488
638
|
|
489
639
|
headers = {
|
@@ -527,6 +677,8 @@ module IBMWatson
|
|
527
677
|
# example, 'text/html;charset=utf-8'.
|
528
678
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
529
679
|
def get_translated_document(document_id:, accept: nil)
|
680
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
681
|
+
|
530
682
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
531
683
|
|
532
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
|
@@ -31,6 +33,8 @@ module IBMWatson
|
|
31
33
|
# The Natural Language Classifier V1 service.
|
32
34
|
class NaturalLanguageClassifierV1 < IBMCloudSdkCore::BaseService
|
33
35
|
include Concurrent::Async
|
36
|
+
DEFAULT_SERVICE_NAME = "natural_language_classifier"
|
37
|
+
DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
34
38
|
##
|
35
39
|
# @!method initialize(args)
|
36
40
|
# Construct a new client for the Natural Language Classifier service.
|
@@ -39,15 +43,19 @@ module IBMWatson
|
|
39
43
|
# @option args service_url [String] The base service URL to use when contacting the service.
|
40
44
|
# The base service_url may differ between IBM Cloud regions.
|
41
45
|
# @option args authenticator [Object] The Authenticator instance to be configured for this service.
|
46
|
+
# @option args service_name [String] The name of the service to configure. Will be used as the key to load
|
47
|
+
# any external configuration, if applicable.
|
42
48
|
def initialize(args = {})
|
43
49
|
@__async_initialized__ = false
|
44
50
|
defaults = {}
|
45
|
-
defaults[:service_url] =
|
51
|
+
defaults[:service_url] = DEFAULT_SERVICE_URL
|
52
|
+
defaults[:service_name] = DEFAULT_SERVICE_NAME
|
46
53
|
defaults[:authenticator] = nil
|
54
|
+
user_service_url = args[:service_url] unless args[:service_url].nil?
|
47
55
|
args = defaults.merge(args)
|
48
|
-
args[:service_name] = "natural_language_classifier"
|
49
56
|
args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
|
50
57
|
super
|
58
|
+
@service_url = user_service_url unless user_service_url.nil?
|
51
59
|
end
|
52
60
|
|
53
61
|
#########################
|