Skip to content

Commit a743cb7

Browse files
jeff-arnapaparazzi0329
authored andcommitted
feat(natural language understanding): update based on api definitions
this removes the 'sentimentModel' functions and models BREAKING CHANGE: removes the 'sentimentModel' functions and models
1 parent d45607b commit a743cb7

File tree

73 files changed

+311
-580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+311
-580
lines changed

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java

+14-222
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2019, 2022.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -12,7 +12,7 @@
1212
*/
1313

1414
/*
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
1616
*/
1717

1818
package com.ibm.watson.natural_language_understanding.v1;
@@ -35,25 +35,18 @@
3535
import com.ibm.watson.natural_language_understanding.v1.model.ClassificationsModelList;
3636
import com.ibm.watson.natural_language_understanding.v1.model.CreateCategoriesModelOptions;
3737
import com.ibm.watson.natural_language_understanding.v1.model.CreateClassificationsModelOptions;
38-
import com.ibm.watson.natural_language_understanding.v1.model.CreateSentimentModelOptions;
3938
import com.ibm.watson.natural_language_understanding.v1.model.DeleteCategoriesModelOptions;
4039
import com.ibm.watson.natural_language_understanding.v1.model.DeleteClassificationsModelOptions;
4140
import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelOptions;
4241
import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults;
43-
import com.ibm.watson.natural_language_understanding.v1.model.DeleteSentimentModelOptions;
4442
import com.ibm.watson.natural_language_understanding.v1.model.GetCategoriesModelOptions;
4543
import com.ibm.watson.natural_language_understanding.v1.model.GetClassificationsModelOptions;
46-
import com.ibm.watson.natural_language_understanding.v1.model.GetSentimentModelOptions;
4744
import com.ibm.watson.natural_language_understanding.v1.model.ListCategoriesModelsOptions;
4845
import com.ibm.watson.natural_language_understanding.v1.model.ListClassificationsModelsOptions;
4946
import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions;
5047
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;
5448
import com.ibm.watson.natural_language_understanding.v1.model.UpdateCategoriesModelOptions;
5549
import com.ibm.watson.natural_language_understanding.v1.model.UpdateClassificationsModelOptions;
56-
import com.ibm.watson.natural_language_understanding.v1.model.UpdateSentimentModelOptions;
5750
import java.util.HashMap;
5851
import java.util.Map;
5952
import java.util.Map.Entry;
@@ -70,12 +63,24 @@
7063
* with Watson Knowledge Studio to detect custom entities and relations in Natural Language
7164
* Understanding.
7265
*
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.&lt;br
68+
* /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;If you would like more information
74+
* or further guidance, please contact IBM Cloud Support.{: deprecated}.
75+
*
7376
* <p>API Version: 1.0 See: https://cloud.ibm.com/docs/natural-language-understanding
7477
*/
7578
public class NaturalLanguageUnderstanding extends BaseService {
7679

80+
/** Default service name used when configuring the `NaturalLanguageUnderstanding` client. */
7781
public static final String DEFAULT_SERVICE_NAME = "natural-language-understanding";
7882

83+
/** Default service endpoint URL. */
7984
public static final String DEFAULT_SERVICE_URL =
8085
"https://api.us-south.natural-language-understanding.watson.cloud.ibm.com";
8186

@@ -290,219 +295,6 @@ public ServiceCall<DeleteModelResults> deleteModel(DeleteModelOptions deleteMode
290295
return createServiceCall(builder.build(), responseConverter);
291296
}
292297

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-
506298
/**
507299
* Create categories model.
508300
*

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2017, 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -43,6 +43,8 @@ public class AnalysisResults extends GenericModel {
4343
protected SentimentResult sentiment;
4444
protected SyntaxResult syntax;
4545

46+
protected AnalysisResults() {}
47+
4648
/**
4749
* Gets the language.
4850
*

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2019, 2020.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -26,6 +26,8 @@ public class AnalysisResultsUsage extends GenericModel {
2626
@SerializedName("text_units")
2727
protected Long textUnits;
2828

29+
protected AnalysisResultsUsage() {}
30+
2931
/**
3032
* Gets the features.
3133
*

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2017, 2022.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -41,6 +41,11 @@ public static class Builder {
4141
private String language;
4242
private Long limitTextCharacters;
4343

44+
/**
45+
* Instantiates a new Builder from an existing AnalyzeOptions instance.
46+
*
47+
* @param analyzeOptions the instance to initialize the Builder with
48+
*/
4449
private Builder(AnalyzeOptions analyzeOptions) {
4550
this.features = analyzeOptions.features;
4651
this.text = analyzeOptions.text;

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2019, 2020.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -19,6 +19,8 @@ public class Author extends GenericModel {
1919

2020
protected String name;
2121

22+
protected Author() {}
23+
2224
/**
2325
* Gets the name.
2426
*

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModel.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -69,6 +69,8 @@ public interface Status {
6969
@SerializedName("last_deployed")
7070
protected Date lastDeployed;
7171

72+
protected CategoriesModel() {}
73+
7274
/**
7375
* Gets the name.
7476
*

natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesModelList.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2021.
2+
* (C) Copyright IBM Corp. 2023.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -20,6 +20,8 @@ public class CategoriesModelList extends GenericModel {
2020

2121
protected List<CategoriesModel> models;
2222

23+
protected CategoriesModelList() {}
24+
2325
/**
2426
* Gets the models.
2527
*

0 commit comments

Comments
 (0)