ibm_watson 0.20.1 → 1.0.0.rc1
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 +46 -60
- data/lib/ibm_watson.rb +0 -2
- data/lib/ibm_watson/assistant_v1.rb +82 -60
- data/lib/ibm_watson/assistant_v2.rb +8 -12
- data/lib/ibm_watson/compare_comply_v1.rb +21 -18
- data/lib/ibm_watson/discovery_v1.rb +107 -55
- data/lib/ibm_watson/language_translator_v3.rb +21 -23
- data/lib/ibm_watson/natural_language_classifier_v1.rb +15 -24
- data/lib/ibm_watson/natural_language_understanding_v1.rb +8 -12
- data/lib/ibm_watson/personality_insights_v3.rb +12 -24
- data/lib/ibm_watson/speech_to_text_v1.rb +90 -54
- data/lib/ibm_watson/text_to_speech_v1.rb +38 -32
- data/lib/ibm_watson/tone_analyzer_v3.rb +13 -24
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +37 -25
- data/test/integration/test_assistant_v1.rb +8 -4
- data/test/integration/test_assistant_v2.rb +6 -1
- data/test/integration/test_compare_comply_v1.rb +6 -2
- data/test/integration/test_discovery_v1.rb +4 -1
- data/test/integration/test_language_translator_v3.rb +4 -16
- data/test/integration/test_natural_language_classifier_v1.rb +4 -1
- data/test/integration/test_natural_language_understanding_v1.rb +4 -1
- data/test/integration/test_personality_insights_v3.rb +5 -2
- data/test/integration/test_speech_to_text_v1.rb +9 -3
- data/test/integration/test_text_to_speech_v1.rb +5 -2
- data/test/integration/test_tone_analyzer_v3.rb +5 -2
- data/test/integration/test_visual_recognition_v3.rb +5 -2
- data/test/test_helper.rb +2 -0
- data/test/unit/test_assistant_v1.rb +269 -133
- data/test/unit/test_assistant_v2.rb +18 -9
- data/test/unit/test_compare_comply_v1.rb +72 -40
- data/test/unit/test_configure_http_client.rb +4 -2
- data/test/unit/test_discovery_v1.rb +297 -152
- data/test/unit/test_language_translator_v3.rb +52 -13
- data/test/unit/test_natural_language_classifier_v1.rb +10 -4
- data/test/unit/test_natural_language_understanding_v1.rb +25 -10
- data/test/unit/test_personality_insights_v3.rb +20 -8
- data/test/unit/test_speech_to_text_v1.rb +84 -21
- data/test/unit/test_text_to_speech_v1.rb +30 -5
- data/test/unit/test_tone_analyzer_v3.rb +30 -12
- data/test/unit/test_vcap_using_personality_insights.rb +12 -4
- data/test/unit/test_visual_recognition_v3.rb +37 -10
- metadata +8 -8
- data/test/unit/test_watson_service.rb +0 -59
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# (C) Copyright IBM Corp. 2019.
|
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.
|
@@ -85,18 +85,9 @@ module IBMWatson
|
|
85
85
|
@__async_initialized__ = false
|
86
86
|
defaults = {}
|
87
87
|
defaults[:url] = "https://stream.watsonplatform.net/text-to-speech/api"
|
88
|
-
defaults[:
|
89
|
-
defaults[:password] = nil
|
90
|
-
defaults[:iam_apikey] = nil
|
91
|
-
defaults[:iam_access_token] = nil
|
92
|
-
defaults[:iam_url] = nil
|
93
|
-
defaults[:iam_client_id] = nil
|
94
|
-
defaults[:iam_client_secret] = nil
|
95
|
-
defaults[:icp4d_access_token] = nil
|
96
|
-
defaults[:icp4d_url] = nil
|
88
|
+
defaults[:authenticator] = nil
|
97
89
|
defaults[:authentication_type] = nil
|
98
90
|
args = defaults.merge(args)
|
99
|
-
args[:vcap_services_name] = "text_to_speech"
|
100
91
|
args[:display_name] = "Text to Speech"
|
101
92
|
super
|
102
93
|
end
|
@@ -123,6 +114,7 @@ module IBMWatson
|
|
123
114
|
|
124
115
|
method_url = "/v1/voices"
|
125
116
|
|
117
|
+
headers = authenticator.authenticate(headers)
|
126
118
|
response = request(
|
127
119
|
method: "GET",
|
128
120
|
url: method_url,
|
@@ -163,6 +155,7 @@ module IBMWatson
|
|
163
155
|
|
164
156
|
method_url = "/v1/voices/%s" % [ERB::Util.url_encode(voice)]
|
165
157
|
|
158
|
+
headers = authenticator.authenticate(headers)
|
166
159
|
response = request(
|
167
160
|
method: "GET",
|
168
161
|
url: method_url,
|
@@ -177,7 +170,7 @@ module IBMWatson
|
|
177
170
|
#########################
|
178
171
|
|
179
172
|
##
|
180
|
-
# @!method synthesize(text:,
|
173
|
+
# @!method synthesize(text:, accept: nil, voice: nil, customization_id: nil)
|
181
174
|
# Synthesize audio.
|
182
175
|
# Synthesizes text to audio that is spoken in the specified voice. The service bases
|
183
176
|
# its understanding of the language for the input text on the specified voice. Use a
|
@@ -265,22 +258,22 @@ module IBMWatson
|
|
265
258
|
# If a request includes invalid query parameters, the service returns a `Warnings`
|
266
259
|
# response header that provides messages about the invalid parameters. The warning
|
267
260
|
# includes a descriptive message and a list of invalid argument strings. For
|
268
|
-
# example, a message such as
|
269
|
-
# arguments
|
270
|
-
#
|
261
|
+
# example, a message such as `"Unknown arguments:"` or `"Unknown url query
|
262
|
+
# arguments:"` followed by a list of the form `"{invalid_arg_1}, {invalid_arg_2}."`
|
263
|
+
# The request succeeds despite the warnings.
|
271
264
|
# @param text [String] The text to synthesize.
|
265
|
+
# @param accept [String] The requested format (MIME type) of the audio. You can use the `Accept` header or
|
266
|
+
# the `accept` parameter to specify the audio format. For more information about
|
267
|
+
# specifying an audio format, see **Audio formats (accept types)** in the method
|
268
|
+
# description.
|
272
269
|
# @param voice [String] The voice to use for synthesis.
|
273
270
|
# @param customization_id [String] The customization ID (GUID) of a custom voice model to use for the synthesis. If a
|
274
271
|
# custom voice model is specified, it is guaranteed to work only if it matches the
|
275
272
|
# language of the indicated voice. You must make the request with credentials for
|
276
273
|
# the instance of the service that owns the custom model. Omit the parameter to use
|
277
274
|
# the specified voice with no customization.
|
278
|
-
# @param accept [String] The requested format (MIME type) of the audio. You can use the `Accept` header or
|
279
|
-
# the `accept` parameter to specify the audio format. For more information about
|
280
|
-
# specifying an audio format, see **Audio formats (accept types)** in the method
|
281
|
-
# description.
|
282
275
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
283
|
-
def synthesize(text:,
|
276
|
+
def synthesize(text:, accept: nil, voice: nil, customization_id: nil)
|
284
277
|
raise ArgumentError.new("text must be provided") if text.nil?
|
285
278
|
|
286
279
|
headers = {
|
@@ -300,6 +293,7 @@ module IBMWatson
|
|
300
293
|
|
301
294
|
method_url = "/v1/synthesize"
|
302
295
|
|
296
|
+
headers = authenticator.authenticate(headers)
|
303
297
|
response = request(
|
304
298
|
method: "POST",
|
305
299
|
url: method_url,
|
@@ -357,6 +351,7 @@ module IBMWatson
|
|
357
351
|
|
358
352
|
method_url = "/v1/pronunciation"
|
359
353
|
|
354
|
+
headers = authenticator.authenticate(headers)
|
360
355
|
response = request(
|
361
356
|
method: "GET",
|
362
357
|
url: method_url,
|
@@ -404,6 +399,7 @@ module IBMWatson
|
|
404
399
|
|
405
400
|
method_url = "/v1/customizations"
|
406
401
|
|
402
|
+
headers = authenticator.authenticate(headers)
|
407
403
|
response = request(
|
408
404
|
method: "POST",
|
409
405
|
url: method_url,
|
@@ -444,6 +440,7 @@ module IBMWatson
|
|
444
440
|
|
445
441
|
method_url = "/v1/customizations"
|
446
442
|
|
443
|
+
headers = authenticator.authenticate(headers)
|
447
444
|
response = request(
|
448
445
|
method: "GET",
|
449
446
|
url: method_url,
|
@@ -470,13 +467,13 @@ module IBMWatson
|
|
470
467
|
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
471
468
|
# representation
|
472
469
|
#
|
473
|
-
# <code><phoneme alphabet
|
474
|
-
# ph
|
470
|
+
# <code><phoneme alphabet="ipa"
|
471
|
+
# ph="təmˈɑto"></phoneme></code>
|
475
472
|
#
|
476
473
|
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
477
474
|
#
|
478
|
-
# <code><phoneme alphabet
|
479
|
-
# ph
|
475
|
+
# <code><phoneme alphabet="ibm"
|
476
|
+
# ph="1gAstroEntxrYFXs"></phoneme></code>
|
480
477
|
#
|
481
478
|
# **Note:** This method is currently a beta release.
|
482
479
|
#
|
@@ -511,6 +508,7 @@ module IBMWatson
|
|
511
508
|
|
512
509
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
513
510
|
|
511
|
+
headers = authenticator.authenticate(headers)
|
514
512
|
request(
|
515
513
|
method: "POST",
|
516
514
|
url: method_url,
|
@@ -546,6 +544,7 @@ module IBMWatson
|
|
546
544
|
|
547
545
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
548
546
|
|
547
|
+
headers = authenticator.authenticate(headers)
|
549
548
|
response = request(
|
550
549
|
method: "GET",
|
551
550
|
url: method_url,
|
@@ -578,6 +577,7 @@ module IBMWatson
|
|
578
577
|
|
579
578
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
580
579
|
|
580
|
+
headers = authenticator.authenticate(headers)
|
581
581
|
request(
|
582
582
|
method: "DELETE",
|
583
583
|
url: method_url,
|
@@ -605,13 +605,13 @@ module IBMWatson
|
|
605
605
|
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
606
606
|
# representation
|
607
607
|
#
|
608
|
-
# <code><phoneme alphabet
|
609
|
-
# ph
|
608
|
+
# <code><phoneme alphabet="ipa"
|
609
|
+
# ph="təmˈɑto"></phoneme></code>
|
610
610
|
#
|
611
611
|
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
612
612
|
#
|
613
|
-
# <code><phoneme alphabet
|
614
|
-
# ph
|
613
|
+
# <code><phoneme alphabet="ibm"
|
614
|
+
# ph="1gAstroEntxrYFXs"></phoneme></code>
|
615
615
|
#
|
616
616
|
# **Note:** This method is currently a beta release.
|
617
617
|
#
|
@@ -649,6 +649,7 @@ module IBMWatson
|
|
649
649
|
|
650
650
|
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
651
651
|
|
652
|
+
headers = authenticator.authenticate(headers)
|
652
653
|
request(
|
653
654
|
method: "POST",
|
654
655
|
url: method_url,
|
@@ -684,6 +685,7 @@ module IBMWatson
|
|
684
685
|
|
685
686
|
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
686
687
|
|
688
|
+
headers = authenticator.authenticate(headers)
|
687
689
|
response = request(
|
688
690
|
method: "GET",
|
689
691
|
url: method_url,
|
@@ -708,13 +710,13 @@ module IBMWatson
|
|
708
710
|
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
709
711
|
# representation
|
710
712
|
#
|
711
|
-
# <code><phoneme alphabet
|
712
|
-
# ph
|
713
|
+
# <code><phoneme alphabet="ipa"
|
714
|
+
# ph="təmˈɑto"></phoneme></code>
|
713
715
|
#
|
714
716
|
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
715
717
|
#
|
716
|
-
# <code><phoneme alphabet
|
717
|
-
# ph
|
718
|
+
# <code><phoneme alphabet="ibm"
|
719
|
+
# ph="1gAstroEntxrYFXs"></phoneme></code>
|
718
720
|
#
|
719
721
|
# **Note:** This method is currently a beta release.
|
720
722
|
#
|
@@ -758,6 +760,7 @@ module IBMWatson
|
|
758
760
|
|
759
761
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
760
762
|
|
763
|
+
headers = authenticator.authenticate(headers)
|
761
764
|
request(
|
762
765
|
method: "PUT",
|
763
766
|
url: method_url,
|
@@ -795,6 +798,7 @@ module IBMWatson
|
|
795
798
|
|
796
799
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
797
800
|
|
801
|
+
headers = authenticator.authenticate(headers)
|
798
802
|
response = request(
|
799
803
|
method: "GET",
|
800
804
|
url: method_url,
|
@@ -831,6 +835,7 @@ module IBMWatson
|
|
831
835
|
|
832
836
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
833
837
|
|
838
|
+
headers = authenticator.authenticate(headers)
|
834
839
|
request(
|
835
840
|
method: "DELETE",
|
836
841
|
url: method_url,
|
@@ -873,6 +878,7 @@ module IBMWatson
|
|
873
878
|
|
874
879
|
method_url = "/v1/user_data"
|
875
880
|
|
881
|
+
headers = authenticator.authenticate(headers)
|
876
882
|
request(
|
877
883
|
method: "DELETE",
|
878
884
|
url: method_url,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# (C) Copyright IBM Corp. 2019.
|
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.
|
@@ -77,12 +77,6 @@ module IBMWatson
|
|
77
77
|
# 'https://iam.cloud.ibm.com/identity/token'.
|
78
78
|
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
79
79
|
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
80
|
-
# @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
|
81
|
-
# fully managed by the application. Responsibility falls on the application to
|
82
|
-
# refresh the token, either before it expires or reactively upon receiving a 401
|
83
|
-
# from the service as any requests made with an expired token will fail.
|
84
|
-
# @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
|
85
|
-
# URL must be passed in.
|
86
80
|
# @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
|
87
81
|
# takes are basic, iam or icp4d.
|
88
82
|
def initialize(args = {})
|
@@ -90,21 +84,14 @@ module IBMWatson
|
|
90
84
|
defaults = {}
|
91
85
|
defaults[:version] = nil
|
92
86
|
defaults[:url] = "https://gateway.watsonplatform.net/tone-analyzer/api"
|
93
|
-
defaults[:
|
94
|
-
defaults[:password] = nil
|
95
|
-
defaults[:iam_apikey] = nil
|
96
|
-
defaults[:iam_access_token] = nil
|
97
|
-
defaults[:iam_url] = nil
|
98
|
-
defaults[:iam_client_id] = nil
|
99
|
-
defaults[:iam_client_secret] = nil
|
100
|
-
defaults[:icp4d_access_token] = nil
|
101
|
-
defaults[:icp4d_url] = nil
|
87
|
+
defaults[:authenticator] = nil
|
102
88
|
defaults[:authentication_type] = nil
|
103
89
|
args = defaults.merge(args)
|
104
|
-
args[:
|
90
|
+
@version = args[:version]
|
91
|
+
raise ArgumentError.new("version must be provided") if @version.nil?
|
92
|
+
|
105
93
|
args[:display_name] = "Tone Analyzer"
|
106
94
|
super
|
107
|
-
@version = args[:version]
|
108
95
|
end
|
109
96
|
|
110
97
|
#########################
|
@@ -112,7 +99,7 @@ module IBMWatson
|
|
112
99
|
#########################
|
113
100
|
|
114
101
|
##
|
115
|
-
# @!method tone(tone_input:,
|
102
|
+
# @!method tone(tone_input:, content_type: nil, sentences: nil, tones: nil, content_language: nil, accept_language: nil)
|
116
103
|
# Analyze general tone.
|
117
104
|
# Use the general-purpose endpoint to analyze the tone of your input content. The
|
118
105
|
# service analyzes the content for emotional and language tones. The method always
|
@@ -136,6 +123,8 @@ module IBMWatson
|
|
136
123
|
# endpoint](https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).
|
137
124
|
# @param tone_input [ToneInput] JSON, plain text, or HTML input that contains the content to be analyzed. For JSON
|
138
125
|
# input, provide an object of type `ToneInput`.
|
126
|
+
# @param content_type [String] The type of the input. A character encoding can be specified by including a
|
127
|
+
# `charset` parameter. For example, 'text/plain;charset=utf-8'.
|
139
128
|
# @param sentences [Boolean] Indicates whether the service is to return an analysis of each individual sentence
|
140
129
|
# in addition to its analysis of the full document. If `true` (the default), the
|
141
130
|
# service returns results for each sentence.
|
@@ -157,16 +146,14 @@ module IBMWatson
|
|
157
146
|
# variants are treated as their parent language; for example, `en-US` is interpreted
|
158
147
|
# as `en`. You can use different languages for **Content-Language** and
|
159
148
|
# **Accept-Language**.
|
160
|
-
# @param content_type [String] The type of the input. A character encoding can be specified by including a
|
161
|
-
# `charset` parameter. For example, 'text/plain;charset=utf-8'.
|
162
149
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
163
|
-
def tone(tone_input:,
|
150
|
+
def tone(tone_input:, content_type: nil, sentences: nil, tones: nil, content_language: nil, accept_language: nil)
|
164
151
|
raise ArgumentError.new("tone_input must be provided") if tone_input.nil?
|
165
152
|
|
166
153
|
headers = {
|
154
|
+
"Content-Type" => content_type,
|
167
155
|
"Content-Language" => content_language,
|
168
|
-
"Accept-Language" => accept_language
|
169
|
-
"Content-Type" => content_type
|
156
|
+
"Accept-Language" => accept_language
|
170
157
|
}
|
171
158
|
sdk_headers = Common.new.get_sdk_headers("tone_analyzer", "V3", "tone")
|
172
159
|
headers.merge!(sdk_headers)
|
@@ -185,6 +172,7 @@ module IBMWatson
|
|
185
172
|
|
186
173
|
method_url = "/v3/tone"
|
187
174
|
|
175
|
+
headers = authenticator.authenticate(headers)
|
188
176
|
response = request(
|
189
177
|
method: "POST",
|
190
178
|
url: method_url,
|
@@ -247,6 +235,7 @@ module IBMWatson
|
|
247
235
|
|
248
236
|
method_url = "/v3/tone_chat"
|
249
237
|
|
238
|
+
headers = authenticator.authenticate(headers)
|
250
239
|
response = request(
|
251
240
|
method: "POST",
|
252
241
|
url: method_url,
|
data/lib/ibm_watson/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright
|
3
|
+
# (C) Copyright IBM Corp. 2019.
|
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.
|
@@ -59,12 +59,6 @@ module IBMWatson
|
|
59
59
|
# 'https://iam.cloud.ibm.com/identity/token'.
|
60
60
|
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
61
61
|
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
62
|
-
# @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
|
63
|
-
# fully managed by the application. Responsibility falls on the application to
|
64
|
-
# refresh the token, either before it expires or reactively upon receiving a 401
|
65
|
-
# from the service as any requests made with an expired token will fail.
|
66
|
-
# @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
|
67
|
-
# URL must be passed in.
|
68
62
|
# @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
|
69
63
|
# takes are basic, iam or icp4d.
|
70
64
|
def initialize(args = {})
|
@@ -72,19 +66,14 @@ module IBMWatson
|
|
72
66
|
defaults = {}
|
73
67
|
defaults[:version] = nil
|
74
68
|
defaults[:url] = "https://gateway.watsonplatform.net/visual-recognition/api"
|
75
|
-
defaults[:
|
76
|
-
defaults[:iam_access_token] = nil
|
77
|
-
defaults[:iam_url] = nil
|
78
|
-
defaults[:iam_client_id] = nil
|
79
|
-
defaults[:iam_client_secret] = nil
|
80
|
-
defaults[:icp4d_access_token] = nil
|
81
|
-
defaults[:icp4d_url] = nil
|
69
|
+
defaults[:authenticator] = nil
|
82
70
|
defaults[:authentication_type] = nil
|
83
71
|
args = defaults.merge(args)
|
84
|
-
args[:
|
72
|
+
@version = args[:version]
|
73
|
+
raise ArgumentError.new("version must be provided") if @version.nil?
|
74
|
+
|
85
75
|
args[:display_name] = "Visual Recognition"
|
86
76
|
super
|
87
|
-
@version = args[:version]
|
88
77
|
end
|
89
78
|
|
90
79
|
#########################
|
@@ -163,6 +152,7 @@ module IBMWatson
|
|
163
152
|
|
164
153
|
method_url = "/v3/classify"
|
165
154
|
|
155
|
+
headers = authenticator.authenticate(headers)
|
166
156
|
response = request(
|
167
157
|
method: "POST",
|
168
158
|
url: method_url,
|
@@ -236,6 +226,7 @@ module IBMWatson
|
|
236
226
|
|
237
227
|
method_url = "/v3/detect_faces"
|
238
228
|
|
229
|
+
headers = authenticator.authenticate(headers)
|
239
230
|
response = request(
|
240
231
|
method: "POST",
|
241
232
|
url: method_url,
|
@@ -254,11 +245,18 @@ module IBMWatson
|
|
254
245
|
# @!method create_classifier(name:, positive_examples:, negative_examples: nil, negative_examples_filename: nil)
|
255
246
|
# Create a classifier.
|
256
247
|
# Train a new multi-faceted classifier on the uploaded image data. Create your
|
257
|
-
# custom classifier with positive or negative
|
258
|
-
# examples, either two positive example files or one positive and
|
259
|
-
# You can upload a maximum of 256 MB per call.
|
248
|
+
# custom classifier with positive or negative example training images. Include at
|
249
|
+
# least two sets of examples, either two positive example files or one positive and
|
250
|
+
# one negative file. You can upload a maximum of 256 MB per call.
|
260
251
|
#
|
261
|
-
#
|
252
|
+
# **Tips when creating:**
|
253
|
+
#
|
254
|
+
# - If you set the **X-Watson-Learning-Opt-Out** header parameter to `true` when you
|
255
|
+
# create a classifier, the example training images are not stored. Save your
|
256
|
+
# training images locally. For more information, see [Data
|
257
|
+
# collection](#data-collection).
|
258
|
+
#
|
259
|
+
# - Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image
|
262
260
|
# file names, and classifier and class names). The service assumes UTF-8 encoding if
|
263
261
|
# it encounters non-ASCII characters.
|
264
262
|
# @param name [String] The name of the new classifier. Encode special characters in UTF-8.
|
@@ -318,6 +316,7 @@ module IBMWatson
|
|
318
316
|
|
319
317
|
method_url = "/v3/classifiers"
|
320
318
|
|
319
|
+
headers = authenticator.authenticate(headers)
|
321
320
|
response = request(
|
322
321
|
method: "POST",
|
323
322
|
url: method_url,
|
@@ -348,6 +347,7 @@ module IBMWatson
|
|
348
347
|
|
349
348
|
method_url = "/v3/classifiers"
|
350
349
|
|
350
|
+
headers = authenticator.authenticate(headers)
|
351
351
|
response = request(
|
352
352
|
method: "GET",
|
353
353
|
url: method_url,
|
@@ -378,6 +378,7 @@ module IBMWatson
|
|
378
378
|
|
379
379
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
380
380
|
|
381
|
+
headers = authenticator.authenticate(headers)
|
381
382
|
response = request(
|
382
383
|
method: "GET",
|
383
384
|
url: method_url,
|
@@ -400,10 +401,17 @@ module IBMWatson
|
|
400
401
|
# file names, and classifier and class names). The service assumes UTF-8 encoding if
|
401
402
|
# it encounters non-ASCII characters.
|
402
403
|
#
|
403
|
-
# **
|
404
|
-
#
|
405
|
-
#
|
406
|
-
#
|
404
|
+
# **Tips about retraining:**
|
405
|
+
#
|
406
|
+
# - You can't update the classifier if the **X-Watson-Learning-Opt-Out** header
|
407
|
+
# parameter was set to `true` when the classifier was created. Training images are
|
408
|
+
# not stored in that case. Instead, create another classifier. For more information,
|
409
|
+
# see [Data collection](#data-collection).
|
410
|
+
#
|
411
|
+
# - Don't make retraining calls on a classifier until the status is ready. When you
|
412
|
+
# submit retraining requests in parallel, the last request overwrites the previous
|
413
|
+
# requests. The `retrained` property shows the last time the classifier retraining
|
414
|
+
# finished.
|
407
415
|
# @param classifier_id [String] The ID of the classifier.
|
408
416
|
# @param positive_examples [File] A .zip file of images that depict the visual subject of a class in the classifier.
|
409
417
|
# The positive examples create or update classes in the classifier. You can include
|
@@ -459,6 +467,7 @@ module IBMWatson
|
|
459
467
|
|
460
468
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
461
469
|
|
470
|
+
headers = authenticator.authenticate(headers)
|
462
471
|
response = request(
|
463
472
|
method: "POST",
|
464
473
|
url: method_url,
|
@@ -489,6 +498,7 @@ module IBMWatson
|
|
489
498
|
|
490
499
|
method_url = "/v3/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
|
491
500
|
|
501
|
+
headers = authenticator.authenticate(headers)
|
492
502
|
request(
|
493
503
|
method: "DELETE",
|
494
504
|
url: method_url,
|
@@ -506,7 +516,7 @@ module IBMWatson
|
|
506
516
|
# @!method get_core_ml_model(classifier_id:)
|
507
517
|
# Retrieve a Core ML model of a classifier.
|
508
518
|
# Download a Core ML model file (.mlmodel) of a custom classifier that returns
|
509
|
-
# <tt
|
519
|
+
# <tt>"core_ml_enabled": true</tt> in the classifier details.
|
510
520
|
# @param classifier_id [String] The ID of the classifier.
|
511
521
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
512
522
|
def get_core_ml_model(classifier_id:)
|
@@ -523,6 +533,7 @@ module IBMWatson
|
|
523
533
|
|
524
534
|
method_url = "/v3/classifiers/%s/core_ml_model" % [ERB::Util.url_encode(classifier_id)]
|
525
535
|
|
536
|
+
headers = authenticator.authenticate(headers)
|
526
537
|
response = request(
|
527
538
|
method: "GET",
|
528
539
|
url: method_url,
|
@@ -563,6 +574,7 @@ module IBMWatson
|
|
563
574
|
|
564
575
|
method_url = "/v3/user_data"
|
565
576
|
|
577
|
+
headers = authenticator.authenticate(headers)
|
566
578
|
request(
|
567
579
|
method: "DELETE",
|
568
580
|
url: method_url,
|