ibm_watson 1.2.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +33 -5
  3. data/lib/ibm_watson/assistant_v1.rb +153 -209
  4. data/lib/ibm_watson/assistant_v2.rb +168 -15
  5. data/lib/ibm_watson/compare_comply_v1.rb +11 -5
  6. data/lib/ibm_watson/discovery_v1.rb +14 -8
  7. data/lib/ibm_watson/discovery_v2.rb +605 -12
  8. data/lib/ibm_watson/language_translator_v3.rb +166 -47
  9. data/lib/ibm_watson/natural_language_classifier_v1.rb +10 -4
  10. data/lib/ibm_watson/natural_language_understanding_v1.rb +19 -15
  11. data/lib/ibm_watson/personality_insights_v3.rb +17 -11
  12. data/lib/ibm_watson/speech_to_text_v1.rb +323 -195
  13. data/lib/ibm_watson/text_to_speech_v1.rb +75 -59
  14. data/lib/ibm_watson/tone_analyzer_v3.rb +11 -5
  15. data/lib/ibm_watson/version.rb +1 -1
  16. data/lib/ibm_watson/visual_recognition_v3.rb +11 -5
  17. data/lib/ibm_watson/visual_recognition_v4.rb +199 -4
  18. data/test/integration/test_assistant_v2.rb +25 -0
  19. data/test/integration/test_compare_comply_v1.rb +1 -12
  20. data/test/integration/test_discovery_v2.rb +118 -6
  21. data/test/integration/test_language_translator_v3.rb +5 -0
  22. data/test/integration/test_speech_to_text_v1.rb +2 -0
  23. data/test/integration/test_visual_recognition_v4.rb +9 -0
  24. data/test/unit/test_assistant_v1.rb +98 -98
  25. data/test/unit/test_assistant_v2.rb +102 -8
  26. data/test/unit/test_compare_comply_v1.rb +20 -20
  27. data/test/unit/test_discovery_v1.rb +125 -125
  28. data/test/unit/test_discovery_v2.rb +262 -29
  29. data/test/unit/test_language_translator_v3.rb +85 -24
  30. data/test/unit/test_natural_language_classifier_v1.rb +17 -17
  31. data/test/unit/test_natural_language_understanding_v1.rb +10 -10
  32. data/test/unit/test_personality_insights_v3.rb +14 -10
  33. data/test/unit/test_speech_to_text_v1.rb +97 -97
  34. data/test/unit/test_text_to_speech_v1.rb +41 -41
  35. data/test/unit/test_tone_analyzer_v3.rb +12 -12
  36. data/test/unit/test_visual_recognition_v3.rb +16 -16
  37. data/test/unit/test_visual_recognition_v4.rb +117 -30
  38. metadata +5 -6
  39. data/test/unit/test_vcap_using_personality_insights.rb +0 -161
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  # IBM Watson™ Language Translator translates text from one language to another.
18
- # The service offers multiple IBM provided translation models that you can customize based
18
+ # The service offers multiple IBM-provided translation models that you can customize based
19
19
  # on your unique terminology and language. Use Language Translator to take news from
20
20
  # across the globe and present it in your language, communicate with your customers in
21
21
  # their own language, and more.
@@ -32,6 +32,8 @@ module IBMWatson
32
32
  # The Language Translator V3 service.
33
33
  class LanguageTranslatorV3 < IBMCloudSdkCore::BaseService
34
34
  include Concurrent::Async
35
+ DEFAULT_SERVICE_NAME = "language_translator"
36
+ DEFAULT_SERVICE_URL = "https://api.us-south.language-translator.watson.cloud.ibm.com"
35
37
  ##
36
38
  # @!method initialize(args)
37
39
  # Construct a new client for the Language Translator service.
@@ -50,21 +52,57 @@ module IBMWatson
50
52
  # @option args service_url [String] The base service URL to use when contacting the service.
51
53
  # The base service_url may differ between IBM Cloud regions.
52
54
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
55
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
56
+ # any external configuration, if applicable.
53
57
  def initialize(args = {})
54
58
  @__async_initialized__ = false
55
59
  defaults = {}
56
60
  defaults[:version] = nil
57
- defaults[:service_url] = "https://gateway.watsonplatform.net/language-translator/api"
61
+ defaults[:service_url] = DEFAULT_SERVICE_URL
62
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
58
63
  defaults[:authenticator] = nil
64
+ user_service_url = args[:service_url] unless args[:service_url].nil?
59
65
  args = defaults.merge(args)
60
66
  @version = args[:version]
61
67
  raise ArgumentError.new("version must be provided") if @version.nil?
62
68
 
63
- args[:service_name] = "language_translator"
64
69
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
65
70
  super
71
+ @service_url = user_service_url unless user_service_url.nil?
66
72
  end
67
73
 
74
+ #########################
75
+ # Languages
76
+ #########################
77
+
78
+ ##
79
+ # @!method list_languages
80
+ # List supported languages.
81
+ # Lists all supported languages. The method returns an array of supported languages
82
+ # with information about each language. Languages are listed in alphabetical order
83
+ # by language code (for example, `af`, `ar`).
84
+ # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
85
+ def list_languages
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,13 +110,23 @@ 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
- # @param text [Array[String]] Input text in UTF-8 encoding. Multiple entries will result in multiple
77
- # translations in the response.
78
- # @param model_id [String] A globally unique string that identifies the underlying model that is used for
79
- # translation.
80
- # @param source [String] Translation source language code.
81
- # @param target [String] Translation target language code.
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
+ # @param text [Array[String]] Input text in UTF-8 encoding. Multiple entries result in multiple translations in
120
+ # the response.
121
+ # @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
122
+ # base model for English-to-German translation. A model ID overrides the `source`
123
+ # and `target` parameters and is required if you use a custom model. If no model ID
124
+ # is specified, you must specify at least a target language.
125
+ # @param source [String] Language code that specifies the language of the input text. If omitted, the
126
+ # service derives the source language from the input text. The input must contain
127
+ # sufficient text for the service to identify the language reliably.
128
+ # @param target [String] Language code that specifies the target language for translation. Required if
129
+ # model ID is not specified.
82
130
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
83
131
  def translate(text:, model_id: nil, source: nil, target: nil)
84
132
  raise ArgumentError.new("text must be provided") if text.nil?
@@ -186,10 +234,11 @@ module IBMWatson
186
234
  # Lists available translation models.
187
235
  # @param source [String] Specify a language code to filter results by source language.
188
236
  # @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 will return all models
237
+ # @param default [Boolean] If the `default` parameter isn't specified, the service returns all models
190
238
  # (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 to `false`. There
192
- # is exactly one default model per language pair, the IBM provided base model.
239
+ # set this parameter to `true`. To return only non-default models, set this
240
+ # parameter to `false`. There is exactly one default model, the IBM-provided base
241
+ # model, per language pair.
193
242
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
194
243
  def list_models(source: nil, target: nil, default: nil)
195
244
  headers = {
@@ -219,36 +268,101 @@ module IBMWatson
219
268
  ##
220
269
  # @!method create_model(base_model_id:, forced_glossary: nil, parallel_corpus: nil, name: nil)
221
270
  # Create model.
222
- # Uploads Translation Memory eXchange (TMX) files to customize a translation model.
271
+ # Uploads training files to customize a translation model. You can customize a model
272
+ # with a forced glossary or with a parallel corpus:
273
+ # * Use a *forced glossary* to force certain terms and phrases to be translated in a
274
+ # specific way. You can upload only a single forced glossary file for a model. The
275
+ # size of a forced glossary file for a custom model is limited to 10 MB.
276
+ # * Use a *parallel corpus* when you want your custom model to learn from general
277
+ # translation patterns in parallel sentences in your samples. What your model learns
278
+ # from a parallel corpus can improve translation results for input text that the
279
+ # model has not been trained on. You can upload multiple parallel corpora files with
280
+ # a request. To successfully train with parallel corpora, the corpora files must
281
+ # contain a cumulative total of at least 5000 parallel sentences. The cumulative
282
+ # size of all uploaded corpus files for a custom model is limited to 250 MB.
283
+ #
284
+ # Depending on the type of customization and the size of the uploaded files,
285
+ # training time can range from minutes for a glossary to several hours for a large
286
+ # parallel corpus. To create a model that is customized with a parallel corpus and a
287
+ # forced glossary, customize the model with a parallel corpus first and then
288
+ # customize the resulting model with a forced glossary.
289
+ #
290
+ # You can create a maximum of 10 custom models per language pair. For more
291
+ # information about customizing a translation model, including the formatting and
292
+ # character restrictions for data files, see [Customizing your
293
+ # model](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing).
294
+ #
295
+ #
296
+ # #### Supported file formats
297
+ #
298
+ # You can provide your training data for customization in the following document
299
+ # formats:
300
+ # * **TMX** (`.tmx`) - Translation Memory eXchange (TMX) is an XML specification for
301
+ # the exchange of translation memories.
302
+ # * **XLIFF** (`.xliff`) - XML Localization Interchange File Format (XLIFF) is an
303
+ # XML specification for the exchange of translation memories.
304
+ # * **CSV** (`.csv`) - Comma-separated values (CSV) file with two columns for
305
+ # aligned sentences and phrases. The first row contains the language code.
306
+ # * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file with two columns
307
+ # for aligned sentences and phrases. The first row contains the language code.
308
+ # * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and
309
+ # phrases.
310
+ # * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns
311
+ # for aligned sentences and phrases. The first row contains the language code.
312
+ #
313
+ # You must encode all text data in UTF-8 format. For more information, see
314
+ # [Supported document formats for training
315
+ # data](https://cloud.ibm.com/docs/language-translator?topic=language-translator-customizing#supported-document-formats-for-training-data).
316
+ #
317
+ #
318
+ # #### Specifying file formats
319
+ #
320
+ # You can indicate the format of a file by including the file extension with the
321
+ # file name. Use the file extensions shown in **Supported file formats**.
322
+ #
323
+ # Alternatively, you can omit the file extension and specify one of the following
324
+ # `content-type` specifications for the file:
325
+ # * **TMX** - `application/x-tmx+xml`
326
+ # * **XLIFF** - `application/xliff+xml`
327
+ # * **CSV** - `text/csv`
328
+ # * **TSV** - `text/tab-separated-values`
329
+ # * **JSON** - `application/json`
330
+ # * **Microsoft Excel** -
331
+ # `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
332
+ #
333
+ # For example, with `curl`, use the following `content-type` specification to
334
+ # indicate the format of a CSV file named **glossary**:
335
+ #
336
+ # `--form "forced_glossary=@glossary;type=text/csv"`.
337
+ # @param base_model_id [String] The ID of the translation model to use as the base for customization. To see
338
+ # available models and IDs, use the `List models` method. Most models that are
339
+ # provided with the service are customizable. In addition, all models that you
340
+ # create with parallel corpora customization can be further customized with a forced
341
+ # glossary.
342
+ # @param forced_glossary [File] A file with forced glossary terms for the source and target languages. The
343
+ # customizations in the file completely overwrite the domain translation data,
344
+ # including high frequency or high confidence phrase translations.
345
+ #
346
+ # You can upload only one glossary file for a custom model, and the glossary can
347
+ # have a maximum size of 10 MB. A forced glossary must contain single words or short
348
+ # phrases. For more information, see **Supported file formats** in the method
349
+ # description.
350
+ #
351
+ # *With `curl`, use `--form forced_glossary=@{filename}`.*.
352
+ # @param parallel_corpus [File] A file with parallel sentences for the source and target languages. You can upload
353
+ # multiple parallel corpus files in one request by repeating the parameter. All
354
+ # uploaded parallel corpus files combined must contain at least 5000 parallel
355
+ # sentences to train successfully. You can provide a maximum of 500,000 parallel
356
+ # sentences across all corpora.
223
357
  #
224
- # You can either customize a model with a forced glossary or with a corpus that
225
- # contains parallel sentences. To create a model that is customized with a parallel
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.
358
+ # A single entry in a corpus file can contain a maximum of 80 words. All corpora
359
+ # files for a custom model can have a cumulative maximum size of 250 MB. For more
360
+ # information, see **Supported file formats** in the method description.
235
361
  #
236
- # You can have a <b>maximum of 10 custom models per language pair</b>.
237
- # @param base_model_id [String] The model ID of the model to use as the base for customization. To see available
238
- # models, use the `List models` method. Usually all IBM provided models are
239
- # customizable. In addition, all your models that have been created via parallel
240
- # corpus customization, can be further customized with a forced glossary.
241
- # @param forced_glossary [File] A TMX file with your customizations. The customizations in the file completely
242
- # overwrite the domain translaton data, including high frequency or high confidence
243
- # phrase translations. You can upload only one glossary with a file size less than
244
- # 10 MB per call. A forced glossary should contain single words or short phrases.
245
- # @param parallel_corpus [File] A TMX file with parallel sentences for source and target language. You can upload
246
- # multiple parallel_corpus files in one request. All uploaded parallel_corpus files
247
- # combined, your parallel corpus must contain at least 5,000 parallel sentences to
248
- # train successfully.
362
+ # *With `curl`, use `--form parallel_corpus=@{filename}`.*.
249
363
  # @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.
364
+ # are letters, numbers, dashes, underscores, spaces, and apostrophes. The maximum
365
+ # length of the name is 32 characters.
252
366
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
253
367
  def create_model(base_model_id:, forced_glossary: nil, parallel_corpus: nil, name: nil)
254
368
  raise ArgumentError.new("base_model_id must be provided") if base_model_id.nil?
@@ -328,7 +442,7 @@ module IBMWatson
328
442
  # Get model details.
329
443
  # Gets information about a translation model, including training status for custom
330
444
  # models. Use this API call to poll the status of your customization request. A
331
- # successfully completed training will have a status of `available`.
445
+ # successfully completed training has a status of `available`.
332
446
  # @param model_id [String] Model ID of the model to get.
333
447
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
334
448
  def get_model(model_id:)
@@ -394,15 +508,20 @@ module IBMWatson
394
508
  # @param file [File] The contents of the source file to translate.
395
509
  #
396
510
  # [Supported file
397
- # types](https://cloud.ibm.com/docs/services/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats)
511
+ # types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats)
398
512
  #
399
513
  # Maximum file size: **20 MB**.
400
514
  # @param filename [String] The filename for file.
401
515
  # @param file_content_type [String] The content type of file.
402
- # @param model_id [String] The model to use for translation. `model_id` or both `source` and `target` are
403
- # required.
404
- # @param source [String] Language code that specifies the language of the source document.
405
- # @param target [String] Language code that specifies the target language for translation.
516
+ # @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
517
+ # base model for English-to-German translation. A model ID overrides the `source`
518
+ # and `target` parameters and is required if you use a custom model. If no model ID
519
+ # is specified, you must specify at least a target language.
520
+ # @param source [String] Language code that specifies the language of the source document. If omitted, the
521
+ # service derives the source language from the input text. The input must contain
522
+ # sufficient text for the service to identify the language reliably.
523
+ # @param target [String] Language code that specifies the target language for translation. Required if
524
+ # model ID is not specified.
406
525
  # @param document_id [String] To use a previously submitted document as the source for a new translation, enter
407
526
  # the `document_id` of the document.
408
527
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@ module IBMWatson
31
31
  # The Natural Language Classifier V1 service.
32
32
  class NaturalLanguageClassifierV1 < IBMCloudSdkCore::BaseService
33
33
  include Concurrent::Async
34
+ DEFAULT_SERVICE_NAME = "natural_language_classifier"
35
+ DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"
34
36
  ##
35
37
  # @!method initialize(args)
36
38
  # Construct a new client for the Natural Language Classifier service.
@@ -39,15 +41,19 @@ module IBMWatson
39
41
  # @option args service_url [String] The base service URL to use when contacting the service.
40
42
  # The base service_url may differ between IBM Cloud regions.
41
43
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
44
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
45
+ # any external configuration, if applicable.
42
46
  def initialize(args = {})
43
47
  @__async_initialized__ = false
44
48
  defaults = {}
45
- defaults[:service_url] = "https://gateway.watsonplatform.net/natural-language-classifier/api"
49
+ defaults[:service_url] = DEFAULT_SERVICE_URL
50
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
46
51
  defaults[:authenticator] = nil
52
+ user_service_url = args[:service_url] unless args[:service_url].nil?
47
53
  args = defaults.merge(args)
48
- args[:service_name] = "natural_language_classifier"
49
54
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
50
55
  super
56
+ @service_url = user_service_url unless user_service_url.nil?
51
57
  end
52
58
 
53
59
  #########################
@@ -141,7 +147,7 @@ module IBMWatson
141
147
  # (`pt`), and Spanish (`es`).
142
148
  # @param training_data [File] Training data in CSV format. Each text value must have at least one class. The
143
149
  # data can include up to 3,000 classes and 20,000 records. For details, see [Data
144
- # preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?topic=natural-language-classifier-using-your-data).
150
+ # preparation](https://cloud.ibm.com/docs/natural-language-classifier?topic=natural-language-classifier-using-your-data).
145
151
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
146
152
  def create_classifier(training_metadata:, training_data:)
147
153
  raise ArgumentError.new("training_metadata must be provided") if training_metadata.nil?
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
20
20
  # can ignore most advertisements and other unwanted content.
21
21
  #
22
22
  # You can create [custom
23
- # models](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing)
23
+ # models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
24
24
  # with Watson Knowledge Studio to detect custom entities and relations in Natural Language
25
25
  # Understanding.
26
26
 
@@ -36,6 +36,8 @@ module IBMWatson
36
36
  # The Natural Language Understanding V1 service.
37
37
  class NaturalLanguageUnderstandingV1 < IBMCloudSdkCore::BaseService
38
38
  include Concurrent::Async
39
+ DEFAULT_SERVICE_NAME = "natural_language_understanding"
40
+ DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"
39
41
  ##
40
42
  # @!method initialize(args)
41
43
  # Construct a new client for the Natural Language Understanding service.
@@ -54,19 +56,23 @@ module IBMWatson
54
56
  # @option args service_url [String] The base service URL to use when contacting the service.
55
57
  # The base service_url may differ between IBM Cloud regions.
56
58
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
59
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
60
+ # any external configuration, if applicable.
57
61
  def initialize(args = {})
58
62
  @__async_initialized__ = false
59
63
  defaults = {}
60
64
  defaults[:version] = nil
61
- defaults[:service_url] = "https://gateway.watsonplatform.net/natural-language-understanding/api"
65
+ defaults[:service_url] = DEFAULT_SERVICE_URL
66
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
62
67
  defaults[:authenticator] = nil
68
+ user_service_url = args[:service_url] unless args[:service_url].nil?
63
69
  args = defaults.merge(args)
64
70
  @version = args[:version]
65
71
  raise ArgumentError.new("version must be provided") if @version.nil?
66
72
 
67
- args[:service_name] = "natural_language_understanding"
68
73
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
69
74
  super
75
+ @service_url = user_service_url unless user_service_url.nil?
70
76
  end
71
77
 
72
78
  #########################
@@ -86,11 +92,11 @@ module IBMWatson
86
92
  # - Relations
87
93
  # - Semantic roles
88
94
  # - Sentiment
89
- # - Syntax (Experimental).
95
+ # - Syntax.
90
96
  #
91
97
  # If a language for the input text is not specified with the `language` parameter,
92
98
  # the service [automatically detects the
93
- # language](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-detectable-languages).
99
+ # language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages).
94
100
  # @param features [Features] Specific features to analyze the document for.
95
101
  # @param text [String] The plain text to analyze. One of the `text`, `html`, or `url` parameters is
96
102
  # required.
@@ -98,12 +104,11 @@ module IBMWatson
98
104
  # required.
99
105
  # @param url [String] The webpage to analyze. One of the `text`, `html`, or `url` parameters is
100
106
  # required.
101
- # @param clean [Boolean] Set this to `false` to disable webpage cleaning. To learn more about webpage
102
- # cleaning, see the [Analyzing
103
- # webpages](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages)
104
- # documentation.
107
+ # @param clean [Boolean] Set this to `false` to disable webpage cleaning. For more information about
108
+ # webpage cleaning, see [Analyzing
109
+ # webpages](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages).
105
110
  # @param xpath [String] An [XPath
106
- # query](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath)
111
+ # query](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-analyzing-webpages#xpath)
107
112
  # to perform on `html` or `url` input. Results of the query will be appended to the
108
113
  # cleaned webpage text before it is analyzed. To analyze only the results of the
109
114
  # XPath query, set the `clean` parameter to `false`.
@@ -111,9 +116,8 @@ module IBMWatson
111
116
  # @param return_analyzed_text [Boolean] Whether or not to return the analyzed text.
112
117
  # @param language [String] ISO 639-1 code that specifies the language of your text. This overrides automatic
113
118
  # language detection. Language support differs depending on the features you include
114
- # in your analysis. See [Language
115
- # support](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-language-support)
116
- # for more information.
119
+ # in your analysis. For more information, see [Language
120
+ # support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support).
117
121
  # @param limit_text_characters [Fixnum] Sets the maximum number of characters that are processed by the service.
118
122
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
119
123
  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)
@@ -161,7 +165,7 @@ module IBMWatson
161
165
  # @!method list_models
162
166
  # List models.
163
167
  # Lists Watson Knowledge Studio [custom entities and relations
164
- # models](https://cloud.ibm.com/docs/services/natural-language-understanding?topic=natural-language-understanding-customizing)
168
+ # models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing)
165
169
  # that are deployed to your Natural Language Understanding service.
166
170
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
167
171
  def list_models
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (C) Copyright IBM Corp. 2020.
3
+ # (C) Copyright IBM Corp. 2018, 2020.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@
26
26
  # is timestamped, can report temporal behavior.
27
27
  # * For information about the meaning of the models that the service uses to describe
28
28
  # personality characteristics, see [Personality
29
- # models](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-models#models).
29
+ # models](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-models#models).
30
30
  # * For information about the meaning of the consumption preferences, see [Consumption
31
- # preferences](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-preferences#preferences).
31
+ # preferences](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-preferences#preferences).
32
32
  #
33
33
  #
34
34
  # **Note:** Request logging is disabled for the Personality Insights service. Regardless
@@ -47,6 +47,8 @@ module IBMWatson
47
47
  # The Personality Insights V3 service.
48
48
  class PersonalityInsightsV3 < IBMCloudSdkCore::BaseService
49
49
  include Concurrent::Async
50
+ DEFAULT_SERVICE_NAME = "personality_insights"
51
+ DEFAULT_SERVICE_URL = "https://api.us-south.personality-insights.watson.cloud.ibm.com"
50
52
  ##
51
53
  # @!method initialize(args)
52
54
  # Construct a new client for the Personality Insights service.
@@ -65,19 +67,23 @@ module IBMWatson
65
67
  # @option args service_url [String] The base service URL to use when contacting the service.
66
68
  # The base service_url may differ between IBM Cloud regions.
67
69
  # @option args authenticator [Object] The Authenticator instance to be configured for this service.
70
+ # @option args service_name [String] The name of the service to configure. Will be used as the key to load
71
+ # any external configuration, if applicable.
68
72
  def initialize(args = {})
69
73
  @__async_initialized__ = false
70
74
  defaults = {}
71
75
  defaults[:version] = nil
72
- defaults[:service_url] = "https://gateway.watsonplatform.net/personality-insights/api"
76
+ defaults[:service_url] = DEFAULT_SERVICE_URL
77
+ defaults[:service_name] = DEFAULT_SERVICE_NAME
73
78
  defaults[:authenticator] = nil
79
+ user_service_url = args[:service_url] unless args[:service_url].nil?
74
80
  args = defaults.merge(args)
75
81
  @version = args[:version]
76
82
  raise ArgumentError.new("version must be provided") if @version.nil?
77
83
 
78
- args[:service_name] = "personality_insights"
79
84
  args[:authenticator] = IBMCloudSdkCore::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: args[:service_name]) if args[:authenticator].nil?
80
85
  super
86
+ @service_url = user_service_url unless user_service_url.nil?
81
87
  end
82
88
 
83
89
  #########################
@@ -95,9 +101,9 @@ module IBMWatson
95
101
  #
96
102
  # **See also:**
97
103
  # * [Requesting a
98
- # profile](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#input)
104
+ # profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#input)
99
105
  # * [Providing sufficient
100
- # input](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#sufficient)
106
+ # input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient)
101
107
  #
102
108
  #
103
109
  # ### Content types
@@ -115,7 +121,7 @@ module IBMWatson
115
121
  # `Content-Type: text/plain;charset=utf-8`.
116
122
  #
117
123
  # **See also:** [Specifying request and response
118
- # formats](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#formats)
124
+ # formats](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#formats)
119
125
  #
120
126
  #
121
127
  # ### Accept types
@@ -127,12 +133,12 @@ module IBMWatson
127
133
  #
128
134
  # **See also:**
129
135
  # * [Understanding a JSON
130
- # profile](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-output#output)
136
+ # profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-output#output)
131
137
  # * [Understanding a CSV
132
- # profile](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-outputCSV#outputCSV).
138
+ # profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV).
133
139
  # @param content [Content] A maximum of 20 MB of content to analyze, though the service requires much less
134
140
  # text; for more information, see [Providing sufficient
135
- # input](https://cloud.ibm.com/docs/services/personality-insights?topic=personality-insights-input#sufficient).
141
+ # input](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-input#sufficient).
136
142
  # For JSON input, provide an object of type `Content`.
137
143
  # @param accept [String] The type of the response. For more information, see **Accept types** in the method
138
144
  # description.