Skip to content

Commit

Permalink
feat(nlu): add new parameter to create/updateClassificationsModel
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed Aug 10, 2022
1 parent a7a6332 commit 680d2c0
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.watson.natural_language_understanding.v1.model;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;

/** Optional classifications training parameters along with model train requests. */
public class ClassificationsTrainingParameters extends GenericModel {

/** Model type selector to train either a single_label or a multi_label classifier. */
public interface ModelType {
/** single_label. */
String SINGLE_LABEL = "single_label";
/** multi_label. */
String MULTI_LABEL = "multi_label";
}

@SerializedName("model_type")
protected String modelType;

/** Builder. */
public static class Builder {
private String modelType;

private Builder(ClassificationsTrainingParameters classificationsTrainingParameters) {
this.modelType = classificationsTrainingParameters.modelType;
}

/** Instantiates a new builder. */
public Builder() {}

/**
* Builds a ClassificationsTrainingParameters.
*
* @return the new ClassificationsTrainingParameters instance
*/
public ClassificationsTrainingParameters build() {
return new ClassificationsTrainingParameters(this);
}

/**
* Set the modelType.
*
* @param modelType the modelType
* @return the ClassificationsTrainingParameters builder
*/
public Builder modelType(String modelType) {
this.modelType = modelType;
return this;
}
}

protected ClassificationsTrainingParameters() {}

protected ClassificationsTrainingParameters(Builder builder) {
modelType = builder.modelType;
}

/**
* New builder.
*
* @return a ClassificationsTrainingParameters builder
*/
public Builder newBuilder() {
return new Builder(this);
}

/**
* Gets the modelType.
*
* <p>Model type selector to train either a single_label or a multi_label classifier.
*
* @return the modelType
*/
public String modelType() {
return modelType;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2021.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -31,6 +31,7 @@ public class CreateClassificationsModelOptions extends GenericModel {
protected String modelVersion;
protected String workspaceId;
protected String versionDescription;
protected ClassificationsTrainingParameters trainingParameters;

/** Builder. */
public static class Builder {
Expand All @@ -43,6 +44,7 @@ public static class Builder {
private String modelVersion;
private String workspaceId;
private String versionDescription;
private ClassificationsTrainingParameters trainingParameters;

private Builder(CreateClassificationsModelOptions createClassificationsModelOptions) {
this.language = createClassificationsModelOptions.language;
Expand All @@ -54,6 +56,7 @@ private Builder(CreateClassificationsModelOptions createClassificationsModelOpti
this.modelVersion = createClassificationsModelOptions.modelVersion;
this.workspaceId = createClassificationsModelOptions.workspaceId;
this.versionDescription = createClassificationsModelOptions.versionDescription;
this.trainingParameters = createClassificationsModelOptions.trainingParameters;
}

/** Instantiates a new builder. */
Expand Down Expand Up @@ -178,6 +181,17 @@ public Builder versionDescription(String versionDescription) {
return this;
}

/**
* Set the trainingParameters.
*
* @param trainingParameters the trainingParameters
* @return the CreateClassificationsModelOptions builder
*/
public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) {
this.trainingParameters = trainingParameters;
return this;
}

/**
* Set the trainingData.
*
Expand All @@ -191,6 +205,8 @@ public Builder trainingData(File trainingData) throws FileNotFoundException {
}
}

protected CreateClassificationsModelOptions() {}

protected CreateClassificationsModelOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null");
com.ibm.cloud.sdk.core.util.Validator.notNull(
Expand All @@ -204,6 +220,7 @@ protected CreateClassificationsModelOptions(Builder builder) {
modelVersion = builder.modelVersion;
workspaceId = builder.workspaceId;
versionDescription = builder.versionDescription;
trainingParameters = builder.trainingParameters;
}

/**
Expand Down Expand Up @@ -316,4 +333,15 @@ public String workspaceId() {
public String versionDescription() {
return versionDescription;
}

/**
* Gets the trainingParameters.
*
* <p>Optional classifications training parameters along with model train requests.
*
* @return the trainingParameters
*/
public ClassificationsTrainingParameters trainingParameters() {
return trainingParameters;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2021.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -32,6 +32,7 @@ public class UpdateClassificationsModelOptions extends GenericModel {
protected String modelVersion;
protected String workspaceId;
protected String versionDescription;
protected ClassificationsTrainingParameters trainingParameters;

/** Builder. */
public static class Builder {
Expand All @@ -45,6 +46,7 @@ public static class Builder {
private String modelVersion;
private String workspaceId;
private String versionDescription;
private ClassificationsTrainingParameters trainingParameters;

private Builder(UpdateClassificationsModelOptions updateClassificationsModelOptions) {
this.modelId = updateClassificationsModelOptions.modelId;
Expand All @@ -57,6 +59,7 @@ private Builder(UpdateClassificationsModelOptions updateClassificationsModelOpti
this.modelVersion = updateClassificationsModelOptions.modelVersion;
this.workspaceId = updateClassificationsModelOptions.workspaceId;
this.versionDescription = updateClassificationsModelOptions.versionDescription;
this.trainingParameters = updateClassificationsModelOptions.trainingParameters;
}

/** Instantiates a new builder. */
Expand Down Expand Up @@ -194,6 +197,17 @@ public Builder versionDescription(String versionDescription) {
return this;
}

/**
* Set the trainingParameters.
*
* @param trainingParameters the trainingParameters
* @return the UpdateClassificationsModelOptions builder
*/
public Builder trainingParameters(ClassificationsTrainingParameters trainingParameters) {
this.trainingParameters = trainingParameters;
return this;
}

/**
* Set the trainingData.
*
Expand All @@ -207,6 +221,8 @@ public Builder trainingData(File trainingData) throws FileNotFoundException {
}
}

protected UpdateClassificationsModelOptions() {}

protected UpdateClassificationsModelOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.modelId, "modelId cannot be empty");
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.language, "language cannot be null");
Expand All @@ -222,6 +238,7 @@ protected UpdateClassificationsModelOptions(Builder builder) {
modelVersion = builder.modelVersion;
workspaceId = builder.workspaceId;
versionDescription = builder.versionDescription;
trainingParameters = builder.trainingParameters;
}

/**
Expand Down Expand Up @@ -345,4 +362,15 @@ public String workspaceId() {
public String versionDescription() {
return versionDescription;
}

/**
* Gets the trainingParameters.
*
* <p>Optional classifications training parameters along with model train requests.
*
* @return the trainingParameters
*/
public ClassificationsTrainingParameters trainingParameters() {
return trainingParameters;
}
}

0 comments on commit 680d2c0

Please sign in to comment.