Skip to content

Commit

Permalink
feat(discov2): update models and add new methods
Browse files Browse the repository at this point in the history
NEW methods: listDocuments, getDocument, listDocumentClassifiers, createDocumentClassifier,
getDocumentClassifier, updateDocumentClassifier, deleteDocumentClassifier,
listDocumentClassifierModels, createDocumentClassifierModels, getDocumentClassifierModels,
updateDocumentClassifierModels, deleteDocumentClassifierModels, getStopwordList, createStopwordList,
deleteStopwordList, listExpansions, createExpansions, deleteExpansions
  • Loading branch information
apaparazzi0329 committed Aug 10, 2022
1 parent 4f4894f commit a29cb73
Show file tree
Hide file tree
Showing 45 changed files with 6,718 additions and 327 deletions.
1,382 changes: 1,088 additions & 294 deletions discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* (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.discovery.v2.model;

import com.ibm.cloud.sdk.core.service.model.GenericModel;

/** An object with details for creating federated document classifier models. */
public class ClassifierFederatedModel extends GenericModel {

protected String field;

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

private Builder(ClassifierFederatedModel classifierFederatedModel) {
this.field = classifierFederatedModel.field;
}

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

/**
* Instantiates a new builder with required properties.
*
* @param field the field
*/
public Builder(String field) {
this.field = field;
}

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

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

protected ClassifierFederatedModel() {}

protected ClassifierFederatedModel(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.field, "field cannot be null");
field = builder.field;
}

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

/**
* Gets the field.
*
* <p>Name of the field that contains the values from which multiple classifier models are
* defined. For example, you can specify a field that lists product lines to create a separate
* model per product line.
*
* @return the field
*/
public String field() {
return field;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* (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.discovery.v2.model;

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

/** An object that contains information about a trained document classifier model. */
public class ClassifierModelEvaluation extends GenericModel {

@SerializedName("micro_average")
protected ModelEvaluationMicroAverage microAverage;

@SerializedName("macro_average")
protected ModelEvaluationMacroAverage macroAverage;

@SerializedName("per_class")
protected List<PerClassModelEvaluation> perClass;

/**
* Gets the microAverage.
*
* <p>A micro-average aggregates the contributions of all classes to compute the average metric.
* Classes refers to the classification labels that are specified in the **answer_field**.
*
* @return the microAverage
*/
public ModelEvaluationMicroAverage getMicroAverage() {
return microAverage;
}

/**
* Gets the macroAverage.
*
* <p>A macro-average computes metric independently for each class and then takes the average.
* Class refers to the classification label that is specified in the **answer_field**.
*
* @return the macroAverage
*/
public ModelEvaluationMacroAverage getMacroAverage() {
return macroAverage;
}

/**
* Gets the perClass.
*
* <p>An array of evaluation metrics, one set of metrics for each class, where class refers to the
* classification label that is specified in the **answer_field**.
*
* @return the perClass
*/
public List<PerClassModelEvaluation> getPerClass() {
return perClass;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2020.
* (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 @@ -30,18 +30,23 @@ public class CollectionDetails extends GenericModel {
protected String language;
protected List<CollectionEnrichment> enrichments;

@SerializedName("smart_document_understanding")
protected CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding;

/** Builder. */
public static class Builder {
private String name;
private String description;
private String language;
private List<CollectionEnrichment> enrichments;
private CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding;

private Builder(CollectionDetails collectionDetails) {
this.name = collectionDetails.name;
this.description = collectionDetails.description;
this.language = collectionDetails.language;
this.enrichments = collectionDetails.enrichments;
this.smartDocumentUnderstanding = collectionDetails.smartDocumentUnderstanding;
}

/** Instantiates a new builder. */
Expand Down Expand Up @@ -123,14 +128,29 @@ public Builder enrichments(List<CollectionEnrichment> enrichments) {
this.enrichments = enrichments;
return this;
}

/**
* Set the smartDocumentUnderstanding.
*
* @param smartDocumentUnderstanding the smartDocumentUnderstanding
* @return the CollectionDetails builder
*/
public Builder smartDocumentUnderstanding(
CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding) {
this.smartDocumentUnderstanding = smartDocumentUnderstanding;
return this;
}
}

protected CollectionDetails() {}

protected CollectionDetails(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null");
name = builder.name;
description = builder.description;
language = builder.language;
enrichments = builder.enrichments;
smartDocumentUnderstanding = builder.smartDocumentUnderstanding;
}

/**
Expand Down Expand Up @@ -189,7 +209,8 @@ public Date created() {
/**
* Gets the language.
*
* <p>The language of the collection.
* <p>The language of the collection. For a list of supported languages, see the [product
* documentation](/docs/discovery-data?topic=discovery-data-language-support).
*
* @return the language
*/
Expand All @@ -200,11 +221,27 @@ public String language() {
/**
* Gets the enrichments.
*
* <p>An array of enrichments that are applied to this collection.
* <p>An array of enrichments that are applied to this collection. To get a list of enrichments
* that are available for a project, use the [List enrichments](#listenrichments) method.
*
* <p>If no enrichments are specified when the collection is created, the default enrichments for
* the project type are applied. For more information about project default settings, see the
* [product documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
*
* @return the enrichments
*/
public List<CollectionEnrichment> enrichments() {
return enrichments;
}

/**
* Gets the smartDocumentUnderstanding.
*
* <p>An object that describes the Smart Document Understanding model for a collection.
*
* @return the smartDocumentUnderstanding
*/
public CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding() {
return smartDocumentUnderstanding;
}
}
Loading

0 comments on commit a29cb73

Please sign in to comment.