Skip to content

Commit 680d2c0

Browse files
feat(nlu): add new parameter to create/updateClassificationsModel
1 parent a7a6332 commit 680d2c0

File tree

3 files changed

+147
-2
lines changed

3 files changed

+147
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2022.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.natural_language_understanding.v1.model;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
17+
18+
/** Optional classifications training parameters along with model train requests. */
19+
public class ClassificationsTrainingParameters extends GenericModel {
20+
21+
/** Model type selector to train either a single_label or a multi_label classifier. */
22+
public interface ModelType {
23+
/** single_label. */
24+
String SINGLE_LABEL = "single_label";
25+
/** multi_label. */
26+
String MULTI_LABEL = "multi_label";
27+
}
28+
29+
@SerializedName("model_type")
30+
protected String modelType;
31+
32+
/** Builder. */
33+
public static class Builder {
34+
private String modelType;
35+
36+
private Builder(ClassificationsTrainingParameters classificationsTrainingParameters) {
37+
this.modelType = classificationsTrainingParameters.modelType;
38+
}
39+
40+
/** Instantiates a new builder. */
41+
public Builder() {}
42+
43+
/**
44+
* Builds a ClassificationsTrainingParameters.
45+
*
46+
* @return the new ClassificationsTrainingParameters instance
47+
*/
48+
public ClassificationsTrainingParameters build() {
49+
return new ClassificationsTrainingParameters(this);
50+
}
51+
52+
/**
53+
* Set the modelType.
54+
*
55+
* @param modelType the modelType
56+
* @return the ClassificationsTrainingParameters builder
57+
*/
58+
public Builder modelType(String modelType) {
59+
this.modelType = modelType;
60+
return this;
61+
}
62+
}
63+
64+
protected ClassificationsTrainingParameters() {}
65+
66+
protected ClassificationsTrainingParameters(Builder builder) {
67+
modelType = builder.modelType;
68+
}
69+
70+
/**
71+
* New builder.
72+
*
73+
* @return a ClassificationsTrainingParameters builder
74+
*/
75+
public Builder newBuilder() {
76+
return new Builder(this);
77+
}
78+
79+
/**
80+
* Gets the modelType.
81+
*
82+
* <p>Model type selector to train either a single_label or a multi_label classifier.
83+
*
84+
* @return the modelType
85+
*/
86+
public String modelType() {
87+
return modelType;
88+
}
89+
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2021.
2+
* (C) Copyright IBM Corp. 2022.
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
@@ -31,6 +31,7 @@ public class CreateClassificationsModelOptions extends GenericModel {
3131
protected String modelVersion;
3232
protected String workspaceId;
3333
protected String versionDescription;
34+
protected ClassificationsTrainingParameters trainingParameters;
3435

3536
/** Builder. */
3637
public static class Builder {
@@ -43,6 +44,7 @@ public static class Builder {
4344
private String modelVersion;
4445
private String workspaceId;
4546
private String versionDescription;
47+
private ClassificationsTrainingParameters trainingParameters;
4648

4749
private Builder(CreateClassificationsModelOptions createClassificationsModelOptions) {
4850
this.language = createClassificationsModelOptions.language;
@@ -54,6 +56,7 @@ private Builder(CreateClassificationsModelOptions createClassificationsModelOpti
5456
this.modelVersion = createClassificationsModelOptions.modelVersion;
5557
this.workspaceId = createClassificationsModelOptions.workspaceId;
5658
this.versionDescription = createClassificationsModelOptions.versionDescription;
59+
this.trainingParameters = createClassificationsModelOptions.trainingParameters;
5760
}
5861

5962
/** Instantiates a new builder. */
@@ -178,6 +181,17 @@ public Builder versionDescription(String versionDescription) {
178181
return this;
179182
}
180183

184+
/**
185+
* Set the trainingParameters.
186+
*
187+
* @param trainingParameters the trainingParameters
188+
* @return the CreateClassificationsModelOptions builder
189+
*/
190+
public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) {
191+
this.trainingParameters = trainingParameters;
192+
return this;
193+
}
194+
181195
/**
182196
* Set the trainingData.
183197
*
@@ -191,6 +205,8 @@ public Builder trainingData(File trainingData) throws FileNotFoundException {
191205
}
192206
}
193207

208+
protected CreateClassificationsModelOptions() {}
209+
194210
protected CreateClassificationsModelOptions(Builder builder) {
195211
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null");
196212
com.ibm.cloud.sdk.core.util.Validator.notNull(
@@ -204,6 +220,7 @@ protected CreateClassificationsModelOptions(Builder builder) {
204220
modelVersion = builder.modelVersion;
205221
workspaceId = builder.workspaceId;
206222
versionDescription = builder.versionDescription;
223+
trainingParameters = builder.trainingParameters;
207224
}
208225

209226
/**
@@ -316,4 +333,15 @@ public String workspaceId() {
316333
public String versionDescription() {
317334
return versionDescription;
318335
}
336+
337+
/**
338+
* Gets the trainingParameters.
339+
*
340+
* <p>Optional classifications training parameters along with model train requests.
341+
*
342+
* @return the trainingParameters
343+
*/
344+
public ClassificationsTrainingParameters trainingParameters() {
345+
return trainingParameters;
346+
}
319347
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2021.
2+
* (C) Copyright IBM Corp. 2022.
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
@@ -32,6 +32,7 @@ public class UpdateClassificationsModelOptions extends GenericModel {
3232
protected String modelVersion;
3333
protected String workspaceId;
3434
protected String versionDescription;
35+
protected ClassificationsTrainingParameters trainingParameters;
3536

3637
/** Builder. */
3738
public static class Builder {
@@ -45,6 +46,7 @@ public static class Builder {
4546
private String modelVersion;
4647
private String workspaceId;
4748
private String versionDescription;
49+
private ClassificationsTrainingParameters trainingParameters;
4850

4951
private Builder(UpdateClassificationsModelOptions updateClassificationsModelOptions) {
5052
this.modelId = updateClassificationsModelOptions.modelId;
@@ -57,6 +59,7 @@ private Builder(UpdateClassificationsModelOptions updateClassificationsModelOpti
5759
this.modelVersion = updateClassificationsModelOptions.modelVersion;
5860
this.workspaceId = updateClassificationsModelOptions.workspaceId;
5961
this.versionDescription = updateClassificationsModelOptions.versionDescription;
62+
this.trainingParameters = updateClassificationsModelOptions.trainingParameters;
6063
}
6164

6265
/** Instantiates a new builder. */
@@ -194,6 +197,17 @@ public Builder versionDescription(String versionDescription) {
194197
return this;
195198
}
196199

200+
/**
201+
* Set the trainingParameters.
202+
*
203+
* @param trainingParameters the trainingParameters
204+
* @return the UpdateClassificationsModelOptions builder
205+
*/
206+
public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) {
207+
this.trainingParameters = trainingParameters;
208+
return this;
209+
}
210+
197211
/**
198212
* Set the trainingData.
199213
*
@@ -207,6 +221,8 @@ public Builder trainingData(File trainingData) throws FileNotFoundException {
207221
}
208222
}
209223

224+
protected UpdateClassificationsModelOptions() {}
225+
210226
protected UpdateClassificationsModelOptions(Builder builder) {
211227
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty");
212228
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null");
@@ -222,6 +238,7 @@ protected UpdateClassificationsModelOptions(Builder builder) {
222238
modelVersion = builder.modelVersion;
223239
workspaceId = builder.workspaceId;
224240
versionDescription = builder.versionDescription;
241+
trainingParameters = builder.trainingParameters;
225242
}
226243

227244
/**
@@ -345,4 +362,15 @@ public String workspaceId() {
345362
public String versionDescription() {
346363
return versionDescription;
347364
}
365+
366+
/**
367+
* Gets the trainingParameters.
368+
*
369+
* <p>Optional classifications training parameters along with model train requests.
370+
*
371+
* @return the trainingParameters
372+
*/
373+
public ClassificationsTrainingParameters trainingParameters() {
374+
return trainingParameters;
375+
}
348376
}

0 commit comments

Comments
 (0)