Skip to content

Commit a29cb73

Browse files
feat(discov2): update models and add new methods
NEW methods: listDocuments, getDocument, listDocumentClassifiers, createDocumentClassifier, getDocumentClassifier, updateDocumentClassifier, deleteDocumentClassifier, listDocumentClassifierModels, createDocumentClassifierModels, getDocumentClassifierModels, updateDocumentClassifierModels, deleteDocumentClassifierModels, getStopwordList, createStopwordList, deleteStopwordList, listExpansions, createExpansions, deleteExpansions
1 parent 4f4894f commit a29cb73

Some content is hidden

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

45 files changed

+6718
-327
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java

Lines changed: 1088 additions & 294 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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.discovery.v2.model;
14+
15+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
16+
17+
/** An object with details for creating federated document classifier models. */
18+
public class ClassifierFederatedModel extends GenericModel {
19+
20+
protected String field;
21+
22+
/** Builder. */
23+
public static class Builder {
24+
private String field;
25+
26+
private Builder(ClassifierFederatedModel classifierFederatedModel) {
27+
this.field = classifierFederatedModel.field;
28+
}
29+
30+
/** Instantiates a new builder. */
31+
public Builder() {}
32+
33+
/**
34+
* Instantiates a new builder with required properties.
35+
*
36+
* @param field the field
37+
*/
38+
public Builder(String field) {
39+
this.field = field;
40+
}
41+
42+
/**
43+
* Builds a ClassifierFederatedModel.
44+
*
45+
* @return the new ClassifierFederatedModel instance
46+
*/
47+
public ClassifierFederatedModel build() {
48+
return new ClassifierFederatedModel(this);
49+
}
50+
51+
/**
52+
* Set the field.
53+
*
54+
* @param field the field
55+
* @return the ClassifierFederatedModel builder
56+
*/
57+
public Builder field(String field) {
58+
this.field = field;
59+
return this;
60+
}
61+
}
62+
63+
protected ClassifierFederatedModel() {}
64+
65+
protected ClassifierFederatedModel(Builder builder) {
66+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.field, "field cannot be null");
67+
field = builder.field;
68+
}
69+
70+
/**
71+
* New builder.
72+
*
73+
* @return a ClassifierFederatedModel builder
74+
*/
75+
public Builder newBuilder() {
76+
return new Builder(this);
77+
}
78+
79+
/**
80+
* Gets the field.
81+
*
82+
* <p>Name of the field that contains the values from which multiple classifier models are
83+
* defined. For example, you can specify a field that lists product lines to create a separate
84+
* model per product line.
85+
*
86+
* @return the field
87+
*/
88+
public String field() {
89+
return field;
90+
}
91+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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.discovery.v2.model;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
17+
import java.util.List;
18+
19+
/** An object that contains information about a trained document classifier model. */
20+
public class ClassifierModelEvaluation extends GenericModel {
21+
22+
@SerializedName("micro_average")
23+
protected ModelEvaluationMicroAverage microAverage;
24+
25+
@SerializedName("macro_average")
26+
protected ModelEvaluationMacroAverage macroAverage;
27+
28+
@SerializedName("per_class")
29+
protected List<PerClassModelEvaluation> perClass;
30+
31+
/**
32+
* Gets the microAverage.
33+
*
34+
* <p>A micro-average aggregates the contributions of all classes to compute the average metric.
35+
* Classes refers to the classification labels that are specified in the **answer_field**.
36+
*
37+
* @return the microAverage
38+
*/
39+
public ModelEvaluationMicroAverage getMicroAverage() {
40+
return microAverage;
41+
}
42+
43+
/**
44+
* Gets the macroAverage.
45+
*
46+
* <p>A macro-average computes metric independently for each class and then takes the average.
47+
* Class refers to the classification label that is specified in the **answer_field**.
48+
*
49+
* @return the macroAverage
50+
*/
51+
public ModelEvaluationMacroAverage getMacroAverage() {
52+
return macroAverage;
53+
}
54+
55+
/**
56+
* Gets the perClass.
57+
*
58+
* <p>An array of evaluation metrics, one set of metrics for each class, where class refers to the
59+
* classification label that is specified in the **answer_field**.
60+
*
61+
* @return the perClass
62+
*/
63+
public List<PerClassModelEvaluation> getPerClass() {
64+
return perClass;
65+
}
66+
}

discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* (C) Copyright IBM Corp. 2020.
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
@@ -30,18 +30,23 @@ public class CollectionDetails extends GenericModel {
3030
protected String language;
3131
protected List<CollectionEnrichment> enrichments;
3232

33+
@SerializedName("smart_document_understanding")
34+
protected CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding;
35+
3336
/** Builder. */
3437
public static class Builder {
3538
private String name;
3639
private String description;
3740
private String language;
3841
private List<CollectionEnrichment> enrichments;
42+
private CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding;
3943

4044
private Builder(CollectionDetails collectionDetails) {
4145
this.name = collectionDetails.name;
4246
this.description = collectionDetails.description;
4347
this.language = collectionDetails.language;
4448
this.enrichments = collectionDetails.enrichments;
49+
this.smartDocumentUnderstanding = collectionDetails.smartDocumentUnderstanding;
4550
}
4651

4752
/** Instantiates a new builder. */
@@ -123,14 +128,29 @@ public Builder enrichments(List<CollectionEnrichment> enrichments) {
123128
this.enrichments = enrichments;
124129
return this;
125130
}
131+
132+
/**
133+
* Set the smartDocumentUnderstanding.
134+
*
135+
* @param smartDocumentUnderstanding the smartDocumentUnderstanding
136+
* @return the CollectionDetails builder
137+
*/
138+
public Builder smartDocumentUnderstanding(
139+
CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding) {
140+
this.smartDocumentUnderstanding = smartDocumentUnderstanding;
141+
return this;
142+
}
126143
}
127144

145+
protected CollectionDetails() {}
146+
128147
protected CollectionDetails(Builder builder) {
129148
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null");
130149
name = builder.name;
131150
description = builder.description;
132151
language = builder.language;
133152
enrichments = builder.enrichments;
153+
smartDocumentUnderstanding = builder.smartDocumentUnderstanding;
134154
}
135155

136156
/**
@@ -189,7 +209,8 @@ public Date created() {
189209
/**
190210
* Gets the language.
191211
*
192-
* <p>The language of the collection.
212+
* <p>The language of the collection. For a list of supported languages, see the [product
213+
* documentation](/docs/discovery-data?topic=discovery-data-language-support).
193214
*
194215
* @return the language
195216
*/
@@ -200,11 +221,27 @@ public String language() {
200221
/**
201222
* Gets the enrichments.
202223
*
203-
* <p>An array of enrichments that are applied to this collection.
224+
* <p>An array of enrichments that are applied to this collection. To get a list of enrichments
225+
* that are available for a project, use the [List enrichments](#listenrichments) method.
226+
*
227+
* <p>If no enrichments are specified when the collection is created, the default enrichments for
228+
* the project type are applied. For more information about project default settings, see the
229+
* [product documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
204230
*
205231
* @return the enrichments
206232
*/
207233
public List<CollectionEnrichment> enrichments() {
208234
return enrichments;
209235
}
236+
237+
/**
238+
* Gets the smartDocumentUnderstanding.
239+
*
240+
* <p>An object that describes the Smart Document Understanding model for a collection.
241+
*
242+
* @return the smartDocumentUnderstanding
243+
*/
244+
public CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding() {
245+
return smartDocumentUnderstanding;
246+
}
210247
}

0 commit comments

Comments
 (0)