|
1 | 1 | /*
|
2 |
| - * (C) Copyright IBM Corp. 2019, 2022. |
| 2 | + * (C) Copyright IBM Corp. 2023. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
5 | 5 | * the License. You may obtain a copy of the License at
|
|
12 | 12 | */
|
13 | 13 |
|
14 | 14 | /*
|
15 |
| - * IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508 |
| 15 | + * IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647 |
16 | 16 | */
|
17 | 17 |
|
18 | 18 | package com.ibm.watson.natural_language_understanding.v1;
|
|
35 | 35 | import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModelList;
|
36 | 36 | import com.ibm.watson.natural_language_understanding.v1.model.CreateCategoriesModelOptions;
|
37 | 37 | import com.ibm.watson.natural_language_understanding.v1.model.CreateClassificationsModelOptions;
|
38 |
| -import com.ibm.watson.natural_language_understanding.v1.model.CreateSentimentModelOptions; |
39 | 38 | import com.ibm.watson.natural_language_understanding.v1.model.DeleteCategoriesModelOptions;
|
40 | 39 | import com.ibm.watson.natural_language_understanding.v1.model.DeleteClassificationsModelOptions;
|
41 | 40 | import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelOptions;
|
42 | 41 | import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults;
|
43 |
| -import com.ibm.watson.natural_language_understanding.v1.model.DeleteSentimentModelOptions; |
44 | 42 | import com.ibm.watson.natural_language_understanding.v1.model.GetCategoriesModelOptions;
|
45 | 43 | import com.ibm.watson.natural_language_understanding.v1.model.GetClassificationsModelOptions;
|
46 |
| -import com.ibm.watson.natural_language_understanding.v1.model.GetSentimentModelOptions; |
47 | 44 | import com.ibm.watson.natural_language_understanding.v1.model.ListCategoriesModelsOptions;
|
48 | 45 | import com.ibm.watson.natural_language_understanding.v1.model.ListClassificationsModelsOptions;
|
49 | 46 | import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions;
|
50 | 47 | import com.ibm.watson.natural_language_understanding.v1.model.ListModelsResults;
|
51 |
| -import com.ibm.watson.natural_language_understanding.v1.model.ListSentimentModelsOptions; |
52 |
| -import com.ibm.watson.natural_language_understanding.v1.model.ListSentimentModelsResponse; |
53 |
| -import com.ibm.watson.natural_language_understanding.v1.model.SentimentModel; |
54 | 48 | import com.ibm.watson.natural_language_understanding.v1.model.UpdateCategoriesModelOptions;
|
55 | 49 | import com.ibm.watson.natural_language_understanding.v1.model.UpdateClassificationsModelOptions;
|
56 |
| -import com.ibm.watson.natural_language_understanding.v1.model.UpdateSentimentModelOptions; |
57 | 50 | import java.util.HashMap;
|
58 | 51 | import java.util.Map;
|
59 | 52 | import java.util.Map.Entry;
|
|
70 | 63 | * with Watson Knowledge Studio to detect custom entities and relations in Natural Language
|
71 | 64 | * Understanding.
|
72 | 65 | *
|
| 66 | + * <p>IBM is sunsetting Watson Natural Language Understanding Custom Sentiment (BETA). From **June |
| 67 | + * 1, 2023** onward, you will no longer be able to use the Custom Sentiment feature.<br |
| 68 | + * /><br />To ensure we continue providing our clients with robust and powerful text |
| 69 | + * classification capabilities, IBM recently announced the general availability of a new |
| 70 | + * [single-label text classification |
| 71 | + * capability](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-classifications). |
| 72 | + * This new feature includes extended language support and training data customizations suited for |
| 73 | + * building a custom sentiment classifier.<br /><br />If you would like more information |
| 74 | + * or further guidance, please contact IBM Cloud Support.{: deprecated}. |
| 75 | + * |
73 | 76 | * <p>API Version: 1.0 See: https://cloud.ibm.com/docs/natural-language-understanding
|
74 | 77 | */
|
75 | 78 | public class NaturalLanguageUnderstanding extends BaseService {
|
76 | 79 |
|
| 80 | + /** Default service name used when configuring the `NaturalLanguageUnderstanding` client. */ |
77 | 81 | public static final String DEFAULT_SERVICE_NAME = "natural-language-understanding";
|
78 | 82 |
|
| 83 | + /** Default service endpoint URL. */ |
79 | 84 | public static final String DEFAULT_SERVICE_URL =
|
80 | 85 | "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com";
|
81 | 86 |
|
@@ -290,219 +295,6 @@ public ServiceCall<DeleteModelResults> deleteModel(DeleteModelOptions deleteMode
|
290 | 295 | return createServiceCall(builder.build(), responseConverter);
|
291 | 296 | }
|
292 | 297 |
|
293 |
| - /** |
294 |
| - * Create sentiment model. |
295 |
| - * |
296 |
| - * <p>(Beta) Creates a custom sentiment model by uploading training data and associated metadata. |
297 |
| - * The model begins the training and deploying process and is ready to use when the `status` is |
298 |
| - * `available`. |
299 |
| - * |
300 |
| - * @param createSentimentModelOptions the {@link CreateSentimentModelOptions} containing the |
301 |
| - * options for the call |
302 |
| - * @return a {@link ServiceCall} with a result of type {@link SentimentModel} |
303 |
| - */ |
304 |
| - public ServiceCall<SentimentModel> createSentimentModel( |
305 |
| - CreateSentimentModelOptions createSentimentModelOptions) { |
306 |
| - com.ibm.cloud.sdk.core.util.Validator.notNull( |
307 |
| - createSentimentModelOptions, "createSentimentModelOptions cannot be null"); |
308 |
| - RequestBuilder builder = |
309 |
| - RequestBuilder.post( |
310 |
| - RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/sentiment")); |
311 |
| - Map<String, String> sdkHeaders = |
312 |
| - SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "createSentimentModel"); |
313 |
| - for (Entry<String, String> header : sdkHeaders.entrySet()) { |
314 |
| - builder.header(header.getKey(), header.getValue()); |
315 |
| - } |
316 |
| - builder.header("Accept", "application/json"); |
317 |
| - builder.query("version", String.valueOf(this.version)); |
318 |
| - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); |
319 |
| - multipartBuilder.setType(MultipartBody.FORM); |
320 |
| - multipartBuilder.addFormDataPart("language", createSentimentModelOptions.language()); |
321 |
| - okhttp3.RequestBody trainingDataBody = |
322 |
| - RequestUtils.inputStreamBody(createSentimentModelOptions.trainingData(), "text/csv"); |
323 |
| - multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); |
324 |
| - if (createSentimentModelOptions.name() != null) { |
325 |
| - multipartBuilder.addFormDataPart("name", createSentimentModelOptions.name()); |
326 |
| - } |
327 |
| - if (createSentimentModelOptions.description() != null) { |
328 |
| - multipartBuilder.addFormDataPart("description", createSentimentModelOptions.description()); |
329 |
| - } |
330 |
| - if (createSentimentModelOptions.modelVersion() != null) { |
331 |
| - multipartBuilder.addFormDataPart("model_version", createSentimentModelOptions.modelVersion()); |
332 |
| - } |
333 |
| - if (createSentimentModelOptions.workspaceId() != null) { |
334 |
| - multipartBuilder.addFormDataPart("workspace_id", createSentimentModelOptions.workspaceId()); |
335 |
| - } |
336 |
| - if (createSentimentModelOptions.versionDescription() != null) { |
337 |
| - multipartBuilder.addFormDataPart( |
338 |
| - "version_description", createSentimentModelOptions.versionDescription()); |
339 |
| - } |
340 |
| - builder.body(multipartBuilder.build()); |
341 |
| - ResponseConverter<SentimentModel> responseConverter = |
342 |
| - ResponseConverterUtils.getValue( |
343 |
| - new com.google.gson.reflect.TypeToken<SentimentModel>() {}.getType()); |
344 |
| - return createServiceCall(builder.build(), responseConverter); |
345 |
| - } |
346 |
| - |
347 |
| - /** |
348 |
| - * List sentiment models. |
349 |
| - * |
350 |
| - * <p>(Beta) Returns all custom sentiment models associated with this service instance. |
351 |
| - * |
352 |
| - * @param listSentimentModelsOptions the {@link ListSentimentModelsOptions} containing the options |
353 |
| - * for the call |
354 |
| - * @return a {@link ServiceCall} with a result of type {@link ListSentimentModelsResponse} |
355 |
| - */ |
356 |
| - public ServiceCall<ListSentimentModelsResponse> listSentimentModels( |
357 |
| - ListSentimentModelsOptions listSentimentModelsOptions) { |
358 |
| - RequestBuilder builder = |
359 |
| - RequestBuilder.get( |
360 |
| - RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models/sentiment")); |
361 |
| - Map<String, String> sdkHeaders = |
362 |
| - SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "listSentimentModels"); |
363 |
| - for (Entry<String, String> header : sdkHeaders.entrySet()) { |
364 |
| - builder.header(header.getKey(), header.getValue()); |
365 |
| - } |
366 |
| - builder.header("Accept", "application/json"); |
367 |
| - builder.query("version", String.valueOf(this.version)); |
368 |
| - ResponseConverter<ListSentimentModelsResponse> responseConverter = |
369 |
| - ResponseConverterUtils.getValue( |
370 |
| - new com.google.gson.reflect.TypeToken<ListSentimentModelsResponse>() {}.getType()); |
371 |
| - return createServiceCall(builder.build(), responseConverter); |
372 |
| - } |
373 |
| - |
374 |
| - /** |
375 |
| - * List sentiment models. |
376 |
| - * |
377 |
| - * <p>(Beta) Returns all custom sentiment models associated with this service instance. |
378 |
| - * |
379 |
| - * @return a {@link ServiceCall} with a result of type {@link ListSentimentModelsResponse} |
380 |
| - */ |
381 |
| - public ServiceCall<ListSentimentModelsResponse> listSentimentModels() { |
382 |
| - return listSentimentModels(null); |
383 |
| - } |
384 |
| - |
385 |
| - /** |
386 |
| - * Get sentiment model details. |
387 |
| - * |
388 |
| - * <p>(Beta) Returns the status of the sentiment model with the given model ID. |
389 |
| - * |
390 |
| - * @param getSentimentModelOptions the {@link GetSentimentModelOptions} containing the options for |
391 |
| - * the call |
392 |
| - * @return a {@link ServiceCall} with a result of type {@link SentimentModel} |
393 |
| - */ |
394 |
| - public ServiceCall<SentimentModel> getSentimentModel( |
395 |
| - GetSentimentModelOptions getSentimentModelOptions) { |
396 |
| - com.ibm.cloud.sdk.core.util.Validator.notNull( |
397 |
| - getSentimentModelOptions, "getSentimentModelOptions cannot be null"); |
398 |
| - Map<String, String> pathParamsMap = new HashMap<String, String>(); |
399 |
| - pathParamsMap.put("model_id", getSentimentModelOptions.modelId()); |
400 |
| - RequestBuilder builder = |
401 |
| - RequestBuilder.get( |
402 |
| - RequestBuilder.resolveRequestUrl( |
403 |
| - getServiceUrl(), "/v1/models/sentiment/{model_id}", pathParamsMap)); |
404 |
| - Map<String, String> sdkHeaders = |
405 |
| - SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "getSentimentModel"); |
406 |
| - for (Entry<String, String> header : sdkHeaders.entrySet()) { |
407 |
| - builder.header(header.getKey(), header.getValue()); |
408 |
| - } |
409 |
| - builder.header("Accept", "application/json"); |
410 |
| - builder.query("version", String.valueOf(this.version)); |
411 |
| - ResponseConverter<SentimentModel> responseConverter = |
412 |
| - ResponseConverterUtils.getValue( |
413 |
| - new com.google.gson.reflect.TypeToken<SentimentModel>() {}.getType()); |
414 |
| - return createServiceCall(builder.build(), responseConverter); |
415 |
| - } |
416 |
| - |
417 |
| - /** |
418 |
| - * Update sentiment model. |
419 |
| - * |
420 |
| - * <p>(Beta) Overwrites the training data associated with this custom sentiment model and retrains |
421 |
| - * the model. The new model replaces the current deployment. |
422 |
| - * |
423 |
| - * @param updateSentimentModelOptions the {@link UpdateSentimentModelOptions} containing the |
424 |
| - * options for the call |
425 |
| - * @return a {@link ServiceCall} with a result of type {@link SentimentModel} |
426 |
| - */ |
427 |
| - public ServiceCall<SentimentModel> updateSentimentModel( |
428 |
| - UpdateSentimentModelOptions updateSentimentModelOptions) { |
429 |
| - com.ibm.cloud.sdk.core.util.Validator.notNull( |
430 |
| - updateSentimentModelOptions, "updateSentimentModelOptions cannot be null"); |
431 |
| - Map<String, String> pathParamsMap = new HashMap<String, String>(); |
432 |
| - pathParamsMap.put("model_id", updateSentimentModelOptions.modelId()); |
433 |
| - RequestBuilder builder = |
434 |
| - RequestBuilder.put( |
435 |
| - RequestBuilder.resolveRequestUrl( |
436 |
| - getServiceUrl(), "/v1/models/sentiment/{model_id}", pathParamsMap)); |
437 |
| - Map<String, String> sdkHeaders = |
438 |
| - SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "updateSentimentModel"); |
439 |
| - for (Entry<String, String> header : sdkHeaders.entrySet()) { |
440 |
| - builder.header(header.getKey(), header.getValue()); |
441 |
| - } |
442 |
| - builder.header("Accept", "application/json"); |
443 |
| - builder.query("version", String.valueOf(this.version)); |
444 |
| - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); |
445 |
| - multipartBuilder.setType(MultipartBody.FORM); |
446 |
| - multipartBuilder.addFormDataPart("language", updateSentimentModelOptions.language()); |
447 |
| - okhttp3.RequestBody trainingDataBody = |
448 |
| - RequestUtils.inputStreamBody(updateSentimentModelOptions.trainingData(), "text/csv"); |
449 |
| - multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody); |
450 |
| - if (updateSentimentModelOptions.name() != null) { |
451 |
| - multipartBuilder.addFormDataPart("name", updateSentimentModelOptions.name()); |
452 |
| - } |
453 |
| - if (updateSentimentModelOptions.description() != null) { |
454 |
| - multipartBuilder.addFormDataPart("description", updateSentimentModelOptions.description()); |
455 |
| - } |
456 |
| - if (updateSentimentModelOptions.modelVersion() != null) { |
457 |
| - multipartBuilder.addFormDataPart("model_version", updateSentimentModelOptions.modelVersion()); |
458 |
| - } |
459 |
| - if (updateSentimentModelOptions.workspaceId() != null) { |
460 |
| - multipartBuilder.addFormDataPart("workspace_id", updateSentimentModelOptions.workspaceId()); |
461 |
| - } |
462 |
| - if (updateSentimentModelOptions.versionDescription() != null) { |
463 |
| - multipartBuilder.addFormDataPart( |
464 |
| - "version_description", updateSentimentModelOptions.versionDescription()); |
465 |
| - } |
466 |
| - builder.body(multipartBuilder.build()); |
467 |
| - ResponseConverter<SentimentModel> responseConverter = |
468 |
| - ResponseConverterUtils.getValue( |
469 |
| - new com.google.gson.reflect.TypeToken<SentimentModel>() {}.getType()); |
470 |
| - return createServiceCall(builder.build(), responseConverter); |
471 |
| - } |
472 |
| - |
473 |
| - /** |
474 |
| - * Delete sentiment model. |
475 |
| - * |
476 |
| - * <p>(Beta) Un-deploys the custom sentiment model with the given model ID and deletes all |
477 |
| - * associated customer data, including any training data or binary artifacts. |
478 |
| - * |
479 |
| - * @param deleteSentimentModelOptions the {@link DeleteSentimentModelOptions} containing the |
480 |
| - * options for the call |
481 |
| - * @return a {@link ServiceCall} with a result of type {@link DeleteModelResults} |
482 |
| - */ |
483 |
| - public ServiceCall<DeleteModelResults> deleteSentimentModel( |
484 |
| - DeleteSentimentModelOptions deleteSentimentModelOptions) { |
485 |
| - com.ibm.cloud.sdk.core.util.Validator.notNull( |
486 |
| - deleteSentimentModelOptions, "deleteSentimentModelOptions cannot be null"); |
487 |
| - Map<String, String> pathParamsMap = new HashMap<String, String>(); |
488 |
| - pathParamsMap.put("model_id", deleteSentimentModelOptions.modelId()); |
489 |
| - RequestBuilder builder = |
490 |
| - RequestBuilder.delete( |
491 |
| - RequestBuilder.resolveRequestUrl( |
492 |
| - getServiceUrl(), "/v1/models/sentiment/{model_id}", pathParamsMap)); |
493 |
| - Map<String, String> sdkHeaders = |
494 |
| - SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "deleteSentimentModel"); |
495 |
| - for (Entry<String, String> header : sdkHeaders.entrySet()) { |
496 |
| - builder.header(header.getKey(), header.getValue()); |
497 |
| - } |
498 |
| - builder.header("Accept", "application/json"); |
499 |
| - builder.query("version", String.valueOf(this.version)); |
500 |
| - ResponseConverter<DeleteModelResults> responseConverter = |
501 |
| - ResponseConverterUtils.getValue( |
502 |
| - new com.google.gson.reflect.TypeToken<DeleteModelResults>() {}.getType()); |
503 |
| - return createServiceCall(builder.build(), responseConverter); |
504 |
| - } |
505 |
| - |
506 | 298 | /**
|
507 | 299 | * Create categories model.
|
508 | 300 | *
|
|
0 commit comments