ibm_watson 1.6.0 → 2.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 +23 -1
- data/lib/ibm_watson/assistant_v1.rb +212 -50
- data/lib/ibm_watson/assistant_v2.rb +66 -12
- data/lib/ibm_watson/compare_comply_v1.rb +33 -20
- data/lib/ibm_watson/discovery_v1.rb +131 -12
- data/lib/ibm_watson/discovery_v2.rb +138 -12
- data/lib/ibm_watson/language_translator_v3.rb +59 -26
- data/lib/ibm_watson/natural_language_classifier_v1.rb +3 -1
- data/lib/ibm_watson/natural_language_understanding_v1.rb +15 -13
- data/lib/ibm_watson/personality_insights_v3.rb +14 -12
- data/lib/ibm_watson/speech_to_text_v1.rb +24 -18
- data/lib/ibm_watson/text_to_speech_v1.rb +96 -119
- data/lib/ibm_watson/tone_analyzer_v3.rb +11 -12
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +23 -12
- data/lib/ibm_watson/visual_recognition_v4.rb +59 -20
- data/test/integration/test_assistant_v1.rb +9 -0
- data/test/integration/test_assistant_v2.rb +9 -0
- data/test/integration/test_text_to_speech_v1.rb +3 -3
- data/test/unit/test_assistant_v1.rb +51 -0
- data/test/unit/test_assistant_v2.rb +51 -0
- data/test/unit/test_discovery_v2.rb +1 -1
- data/test/unit/test_text_to_speech_v1.rb +7 -7
- metadata +5 -5
@@ -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.17.0-8d569e8f-20201030-142059
|
18
|
+
#
|
17
19
|
# IBM Watson™ Discovery is a cognitive search and content analytics engine that
|
18
20
|
# you can add to applications to identify patterns, trends and actionable insights to
|
19
21
|
# drive better decision-making. Securely unify structured and unstructured data with
|
@@ -34,21 +36,14 @@ module IBMWatson
|
|
34
36
|
include Concurrent::Async
|
35
37
|
DEFAULT_SERVICE_NAME = "discovery"
|
36
38
|
DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"
|
39
|
+
attr_accessor :version
|
37
40
|
##
|
38
41
|
# @!method initialize(args)
|
39
42
|
# Construct a new client for the Discovery 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 `2019-11-22`.
|
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]
|
@@ -85,6 +80,8 @@ module IBMWatson
|
|
85
80
|
def list_collections(project_id:)
|
86
81
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
87
82
|
|
83
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
84
|
+
|
88
85
|
headers = {
|
89
86
|
}
|
90
87
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_collections")
|
@@ -118,6 +115,8 @@ module IBMWatson
|
|
118
115
|
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
119
116
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
120
117
|
def create_collection(project_id:, name:, description: nil, language: nil, enrichments: nil)
|
118
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
119
|
+
|
121
120
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
122
121
|
|
123
122
|
raise ArgumentError.new("name must be provided") if name.nil?
|
@@ -160,6 +159,8 @@ module IBMWatson
|
|
160
159
|
# @param collection_id [String] The ID of the collection.
|
161
160
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
162
161
|
def get_collection(project_id:, collection_id:)
|
162
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
163
|
+
|
163
164
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
164
165
|
|
165
166
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -197,6 +198,8 @@ module IBMWatson
|
|
197
198
|
# @param enrichments [Array[CollectionEnrichment]] An array of enrichments that are applied to this collection.
|
198
199
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
199
200
|
def update_collection(project_id:, collection_id:, name: nil, description: nil, enrichments: nil)
|
201
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
202
|
+
|
200
203
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
201
204
|
|
202
205
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -239,6 +242,8 @@ module IBMWatson
|
|
239
242
|
# @param collection_id [String] The ID of the collection.
|
240
243
|
# @return [nil]
|
241
244
|
def delete_collection(project_id:, collection_id:)
|
245
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
246
|
+
|
242
247
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
243
248
|
|
244
249
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -315,6 +320,8 @@ module IBMWatson
|
|
315
320
|
def query(project_id:, collection_ids: nil, filter: nil, query: nil, natural_language_query: nil, aggregation: nil, count: nil, _return: nil, offset: nil, sort: nil, highlight: nil, spelling_suggestions: nil, table_results: nil, suggested_refinements: nil, passages: nil)
|
316
321
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
317
322
|
|
323
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
324
|
+
|
318
325
|
headers = {
|
319
326
|
}
|
320
327
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "query")
|
@@ -371,6 +378,8 @@ module IBMWatson
|
|
371
378
|
def get_autocompletion(project_id:, prefix:, collection_ids: nil, field: nil, count: nil)
|
372
379
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
373
380
|
|
381
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
382
|
+
|
374
383
|
raise ArgumentError.new("prefix must be provided") if prefix.nil?
|
375
384
|
|
376
385
|
headers = {
|
@@ -422,6 +431,8 @@ module IBMWatson
|
|
422
431
|
# one query is **10000**.
|
423
432
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
424
433
|
def query_notices(project_id:, filter: nil, query: nil, natural_language_query: nil, count: nil, offset: nil)
|
434
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
435
|
+
|
425
436
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
426
437
|
|
427
438
|
headers = {
|
@@ -461,6 +472,8 @@ module IBMWatson
|
|
461
472
|
# all collections in the project are used.
|
462
473
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
463
474
|
def list_fields(project_id:, collection_ids: nil)
|
475
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
476
|
+
|
464
477
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
465
478
|
|
466
479
|
headers = {
|
@@ -499,6 +512,8 @@ module IBMWatson
|
|
499
512
|
def get_component_settings(project_id:)
|
500
513
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
501
514
|
|
515
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
516
|
+
|
502
517
|
headers = {
|
503
518
|
}
|
504
519
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "get_component_settings")
|
@@ -580,6 +595,8 @@ module IBMWatson
|
|
580
595
|
# that collection is shared with other collections.
|
581
596
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
582
597
|
def add_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
|
598
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
599
|
+
|
583
600
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
584
601
|
|
585
602
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -659,6 +676,8 @@ module IBMWatson
|
|
659
676
|
# that collection is shared with other collections.
|
660
677
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
661
678
|
def update_document(project_id:, collection_id:, document_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil, x_watson_discovery_force: nil)
|
679
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
680
|
+
|
662
681
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
663
682
|
|
664
683
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -721,6 +740,8 @@ module IBMWatson
|
|
721
740
|
# that collection is shared with other collections.
|
722
741
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
723
742
|
def delete_document(project_id:, collection_id:, document_id:, x_watson_discovery_force: nil)
|
743
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
744
|
+
|
724
745
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
725
746
|
|
726
747
|
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
@@ -760,6 +781,8 @@ module IBMWatson
|
|
760
781
|
# Discovery administrative tooling.
|
761
782
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
762
783
|
def list_training_queries(project_id:)
|
784
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
785
|
+
|
763
786
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
764
787
|
|
765
788
|
headers = {
|
@@ -791,6 +814,8 @@ module IBMWatson
|
|
791
814
|
# Discovery administrative tooling.
|
792
815
|
# @return [nil]
|
793
816
|
def delete_training_queries(project_id:)
|
817
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
818
|
+
|
794
819
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
795
820
|
|
796
821
|
headers = {
|
@@ -827,6 +852,8 @@ module IBMWatson
|
|
827
852
|
# applied.
|
828
853
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
829
854
|
def create_training_query(project_id:, natural_language_query:, examples:, filter: nil)
|
855
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
856
|
+
|
830
857
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
831
858
|
|
832
859
|
raise ArgumentError.new("natural_language_query must be provided") if natural_language_query.nil?
|
@@ -871,6 +898,8 @@ module IBMWatson
|
|
871
898
|
# @param query_id [String] The ID of the query used for training.
|
872
899
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
873
900
|
def get_training_query(project_id:, query_id:)
|
901
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
902
|
+
|
874
903
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
875
904
|
|
876
905
|
raise ArgumentError.new("query_id must be provided") if query_id.nil?
|
@@ -909,6 +938,8 @@ module IBMWatson
|
|
909
938
|
# applied.
|
910
939
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
911
940
|
def update_training_query(project_id:, query_id:, natural_language_query:, examples:, filter: nil)
|
941
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
942
|
+
|
912
943
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
913
944
|
|
914
945
|
raise ArgumentError.new("query_id must be provided") if query_id.nil?
|
@@ -945,6 +976,79 @@ module IBMWatson
|
|
945
976
|
response
|
946
977
|
end
|
947
978
|
#########################
|
979
|
+
# analyze
|
980
|
+
#########################
|
981
|
+
|
982
|
+
##
|
983
|
+
# @!method analyze_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
|
984
|
+
# Analyze a Document.
|
985
|
+
# Process a document using the specified collection's settings and return it for
|
986
|
+
# realtime use.
|
987
|
+
#
|
988
|
+
# **Note:** Documents processed using this method are not added to the specified
|
989
|
+
# collection.
|
990
|
+
#
|
991
|
+
# **Note:** This method is only supported on IBM Cloud Pak for Data instances of
|
992
|
+
# Discovery.
|
993
|
+
# @param project_id [String] The ID of the project. This information can be found from the deploy page of the
|
994
|
+
# Discovery administrative tooling.
|
995
|
+
# @param collection_id [String] The ID of the collection.
|
996
|
+
# @param file [File] The content of the document to ingest. The maximum supported file size when adding
|
997
|
+
# a file to a collection is 50 megabytes, the maximum supported file size when
|
998
|
+
# testing a configuration is 1 megabyte. Files larger than the supported size are
|
999
|
+
# rejected.
|
1000
|
+
# @param filename [String] The filename for file.
|
1001
|
+
# @param file_content_type [String] The content type of file.
|
1002
|
+
# @param metadata [String] The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB
|
1003
|
+
# are rejected.
|
1004
|
+
#
|
1005
|
+
#
|
1006
|
+
# Example: ``` {
|
1007
|
+
# "Creator": "Johnny Appleseed",
|
1008
|
+
# "Subject": "Apples"
|
1009
|
+
# } ```.
|
1010
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1011
|
+
def analyze_document(project_id:, collection_id:, file: nil, filename: nil, file_content_type: nil, metadata: nil)
|
1012
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1013
|
+
|
1014
|
+
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1015
|
+
|
1016
|
+
raise ArgumentError.new("collection_id must be provided") if collection_id.nil?
|
1017
|
+
|
1018
|
+
headers = {
|
1019
|
+
}
|
1020
|
+
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "analyze_document")
|
1021
|
+
headers.merge!(sdk_headers)
|
1022
|
+
|
1023
|
+
params = {
|
1024
|
+
"version" => @version
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
form_data = {}
|
1028
|
+
|
1029
|
+
unless file.nil?
|
1030
|
+
unless file.instance_of?(StringIO) || file.instance_of?(File)
|
1031
|
+
file = file.respond_to?(:to_json) ? StringIO.new(file.to_json) : StringIO.new(file)
|
1032
|
+
end
|
1033
|
+
filename = file.path if filename.nil? && file.respond_to?(:path)
|
1034
|
+
form_data[:file] = HTTP::FormData::File.new(file, content_type: file_content_type.nil? ? "application/octet-stream" : file_content_type, filename: filename)
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
form_data[:metadata] = HTTP::FormData::Part.new(metadata.to_s, content_type: "text/plain") unless metadata.nil?
|
1038
|
+
|
1039
|
+
method_url = "/v2/projects/%s/collections/%s/analyze" % [ERB::Util.url_encode(project_id), ERB::Util.url_encode(collection_id)]
|
1040
|
+
|
1041
|
+
response = request(
|
1042
|
+
method: "POST",
|
1043
|
+
url: method_url,
|
1044
|
+
headers: headers,
|
1045
|
+
params: params,
|
1046
|
+
form: form_data,
|
1047
|
+
accept_json: true
|
1048
|
+
)
|
1049
|
+
response
|
1050
|
+
end
|
1051
|
+
#########################
|
948
1052
|
# enrichments
|
949
1053
|
#########################
|
950
1054
|
|
@@ -956,6 +1060,8 @@ module IBMWatson
|
|
956
1060
|
# Discovery administrative tooling.
|
957
1061
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
958
1062
|
def list_enrichments(project_id:)
|
1063
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1064
|
+
|
959
1065
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
960
1066
|
|
961
1067
|
headers = {
|
@@ -989,6 +1095,8 @@ module IBMWatson
|
|
989
1095
|
# @param file [File] The enrichment file to upload.
|
990
1096
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
991
1097
|
def create_enrichment(project_id:, enrichment:, file: nil)
|
1098
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1099
|
+
|
992
1100
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
993
1101
|
|
994
1102
|
raise ArgumentError.new("enrichment must be provided") if enrichment.nil?
|
@@ -1035,6 +1143,8 @@ module IBMWatson
|
|
1035
1143
|
# @param enrichment_id [String] The ID of the enrichment.
|
1036
1144
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1037
1145
|
def get_enrichment(project_id:, enrichment_id:)
|
1146
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1147
|
+
|
1038
1148
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1039
1149
|
|
1040
1150
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1071,6 +1181,8 @@ module IBMWatson
|
|
1071
1181
|
# @param description [String] A new description for the enrichment.
|
1072
1182
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1073
1183
|
def update_enrichment(project_id:, enrichment_id:, name:, description: nil)
|
1184
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1185
|
+
|
1074
1186
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1075
1187
|
|
1076
1188
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1115,6 +1227,8 @@ module IBMWatson
|
|
1115
1227
|
# @param enrichment_id [String] The ID of the enrichment.
|
1116
1228
|
# @return [nil]
|
1117
1229
|
def delete_enrichment(project_id:, enrichment_id:)
|
1230
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1231
|
+
|
1118
1232
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1119
1233
|
|
1120
1234
|
raise ArgumentError.new("enrichment_id must be provided") if enrichment_id.nil?
|
@@ -1149,6 +1263,8 @@ module IBMWatson
|
|
1149
1263
|
# Lists existing projects for this instance.
|
1150
1264
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1151
1265
|
def list_projects
|
1266
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1267
|
+
|
1152
1268
|
headers = {
|
1153
1269
|
}
|
1154
1270
|
sdk_headers = Common.new.get_sdk_headers("discovery", "V2", "list_projects")
|
@@ -1179,6 +1295,8 @@ module IBMWatson
|
|
1179
1295
|
# @param default_query_parameters [DefaultQueryParams] Default query parameters for this project.
|
1180
1296
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1181
1297
|
def create_project(name:, type:, default_query_parameters: nil)
|
1298
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1299
|
+
|
1182
1300
|
raise ArgumentError.new("name must be provided") if name.nil?
|
1183
1301
|
|
1184
1302
|
raise ArgumentError.new("type must be provided") if type.nil?
|
@@ -1219,6 +1337,8 @@ module IBMWatson
|
|
1219
1337
|
# Discovery administrative tooling.
|
1220
1338
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1221
1339
|
def get_project(project_id:)
|
1340
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1341
|
+
|
1222
1342
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1223
1343
|
|
1224
1344
|
headers = {
|
@@ -1251,6 +1371,8 @@ module IBMWatson
|
|
1251
1371
|
# @param name [String] The new name to give this project.
|
1252
1372
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1253
1373
|
def update_project(project_id:, name: nil)
|
1374
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1375
|
+
|
1254
1376
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1255
1377
|
|
1256
1378
|
headers = {
|
@@ -1290,6 +1412,8 @@ module IBMWatson
|
|
1290
1412
|
# Discovery administrative tooling.
|
1291
1413
|
# @return [nil]
|
1292
1414
|
def delete_project(project_id:)
|
1415
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1416
|
+
|
1293
1417
|
raise ArgumentError.new("project_id must be provided") if project_id.nil?
|
1294
1418
|
|
1295
1419
|
headers = {
|
@@ -1332,6 +1456,8 @@ module IBMWatson
|
|
1332
1456
|
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
1333
1457
|
# @return [nil]
|
1334
1458
|
def delete_user_data(customer_id:)
|
1459
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
1460
|
+
|
1335
1461
|
raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
|
1336
1462
|
|
1337
1463
|
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.17.0-8d569e8f-20201030-142059
|
18
|
+
#
|
17
19
|
# IBM Watson™ Language Translator translates text from one language to another.
|
18
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
|
@@ -34,21 +36,14 @@ module IBMWatson
|
|
34
36
|
include Concurrent::Async
|
35
37
|
DEFAULT_SERVICE_NAME = "language_translator"
|
36
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]
|
@@ -78,11 +73,16 @@ module IBMWatson
|
|
78
73
|
##
|
79
74
|
# @!method list_languages
|
80
75
|
# List supported languages.
|
81
|
-
# Lists all supported languages. The method returns an array of
|
82
|
-
# with information about each language. Languages are listed in
|
83
|
-
# by language code (for example, `af`, `ar`).
|
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`.
|
84
82
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
85
83
|
def list_languages
|
84
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
85
|
+
|
86
86
|
headers = {
|
87
87
|
}
|
88
88
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_languages")
|
@@ -116,8 +116,12 @@ module IBMWatson
|
|
116
116
|
# service attempt to detect the language from the input text. If you omit the source
|
117
117
|
# language, the request must contain sufficient input text for the service to
|
118
118
|
# identify the source language.
|
119
|
-
#
|
120
|
-
#
|
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.
|
121
125
|
# @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
|
122
126
|
# base model for English-to-German translation. A model ID overrides the `source`
|
123
127
|
# and `target` parameters and is required if you use a custom model. If no model ID
|
@@ -129,6 +133,8 @@ module IBMWatson
|
|
129
133
|
# model ID is not specified.
|
130
134
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
131
135
|
def translate(text:, model_id: nil, source: nil, target: nil)
|
136
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
137
|
+
|
132
138
|
raise ArgumentError.new("text must be provided") if text.nil?
|
133
139
|
|
134
140
|
headers = {
|
@@ -170,6 +176,8 @@ module IBMWatson
|
|
170
176
|
# example, `en` for English or `es` for Spanish) and name of each language.
|
171
177
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
172
178
|
def list_identifiable_languages
|
179
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
180
|
+
|
173
181
|
headers = {
|
174
182
|
}
|
175
183
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_identifiable_languages")
|
@@ -198,6 +206,8 @@ module IBMWatson
|
|
198
206
|
# @param text [String] Input text in UTF-8 format.
|
199
207
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
200
208
|
def identify(text:)
|
209
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
210
|
+
|
201
211
|
raise ArgumentError.new("text must be provided") if text.nil?
|
202
212
|
|
203
213
|
headers = {
|
@@ -241,6 +251,8 @@ module IBMWatson
|
|
241
251
|
# model, per language pair.
|
242
252
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
243
253
|
def list_models(source: nil, target: nil, default: nil)
|
254
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
255
|
+
|
244
256
|
headers = {
|
245
257
|
}
|
246
258
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_models")
|
@@ -302,9 +314,13 @@ module IBMWatson
|
|
302
314
|
# * **XLIFF** (`.xliff`) - XML Localization Interchange File Format (XLIFF) is an
|
303
315
|
# XML specification for the exchange of translation memories.
|
304
316
|
# * **CSV** (`.csv`) - Comma-separated values (CSV) file with two columns for
|
305
|
-
# aligned sentences and phrases. The first row
|
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.
|
306
320
|
# * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file with two columns
|
307
|
-
# for aligned sentences and phrases. The first row
|
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.
|
308
324
|
# * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and
|
309
325
|
# phrases.
|
310
326
|
# * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns
|
@@ -365,6 +381,8 @@ module IBMWatson
|
|
365
381
|
# length of the name is 32 characters.
|
366
382
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
367
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
|
+
|
368
386
|
raise ArgumentError.new("base_model_id must be provided") if base_model_id.nil?
|
369
387
|
|
370
388
|
headers = {
|
@@ -414,6 +432,8 @@ module IBMWatson
|
|
414
432
|
# @param model_id [String] Model ID of the model to delete.
|
415
433
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
416
434
|
def delete_model(model_id:)
|
435
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
436
|
+
|
417
437
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
418
438
|
|
419
439
|
headers = {
|
@@ -446,6 +466,8 @@ module IBMWatson
|
|
446
466
|
# @param model_id [String] Model ID of the model to get.
|
447
467
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
448
468
|
def get_model(model_id:)
|
469
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
470
|
+
|
449
471
|
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
450
472
|
|
451
473
|
headers = {
|
@@ -478,6 +500,8 @@ module IBMWatson
|
|
478
500
|
# Lists documents that have been submitted for translation.
|
479
501
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
480
502
|
def list_documents
|
503
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
504
|
+
|
481
505
|
headers = {
|
482
506
|
}
|
483
507
|
sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_documents")
|
@@ -504,13 +528,14 @@ module IBMWatson
|
|
504
528
|
# Translate document.
|
505
529
|
# Submit a document for translation. You can submit the document contents in the
|
506
530
|
# `file` parameter, or you can reference a previously submitted document by document
|
507
|
-
# ID.
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
512
|
-
#
|
513
|
-
#
|
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).
|
514
539
|
# @param filename [String] The filename for file.
|
515
540
|
# @param file_content_type [String] The content type of file.
|
516
541
|
# @param model_id [String] The model to use for translation. For example, `en-de` selects the IBM-provided
|
@@ -526,6 +551,8 @@ module IBMWatson
|
|
526
551
|
# the `document_id` of the document.
|
527
552
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
528
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
|
+
|
529
556
|
raise ArgumentError.new("file must be provided") if file.nil?
|
530
557
|
|
531
558
|
headers = {
|
@@ -573,6 +600,8 @@ module IBMWatson
|
|
573
600
|
# @param document_id [String] The document ID of the document.
|
574
601
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
575
602
|
def get_document_status(document_id:)
|
603
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
604
|
+
|
576
605
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
577
606
|
|
578
607
|
headers = {
|
@@ -603,6 +632,8 @@ module IBMWatson
|
|
603
632
|
# @param document_id [String] Document ID of the document to delete.
|
604
633
|
# @return [nil]
|
605
634
|
def delete_document(document_id:)
|
635
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
636
|
+
|
606
637
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
607
638
|
|
608
639
|
headers = {
|
@@ -646,6 +677,8 @@ module IBMWatson
|
|
646
677
|
# example, 'text/html;charset=utf-8'.
|
647
678
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
648
679
|
def get_translated_document(document_id:, accept: nil)
|
680
|
+
raise ArgumentError.new("version must be provided") if version.nil?
|
681
|
+
|
649
682
|
raise ArgumentError.new("document_id must be provided") if document_id.nil?
|
650
683
|
|
651
684
|
headers = {
|