Skip to content

Commit 495295f

Browse files
committed
feat(discovery-v2): 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 fb05fb6 commit 495295f

Some content is hidden

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

43 files changed

+3834
-851
lines changed

src/IBM.Watson.Discovery.v2/DiscoveryService.cs

Lines changed: 2316 additions & 792 deletions
Large diffs are not rendered by default.

src/IBM.Watson.Discovery.v2/Examples/IBM.Watson.Discovery.v2.Examples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="IBM.Cloud.SDK.Core" Version="1.2.0" />
9+
<PackageReference Include="IBM.Cloud.SDK.Core" Version="1.3.1" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

src/IBM.Watson.Discovery.v2/IBM.Watson.Discovery.v2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</ItemGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="IBM.Cloud.SDK.Core" Version="1.2.0" />
37+
<PackageReference Include="IBM.Cloud.SDK.Core" Version="1.3.1" />
3838
<PackageReference Include="IBM.Watson.Common" Version="6.0.0" />
3939
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
4040
<PackageReference Include="JsonSubTypes" Version="1.6.0" />

src/IBM.Watson.Discovery.v2/IDiscoveryService.cs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2021.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,37 +23,55 @@ namespace IBM.Watson.Discovery.v2
2323
{
2424
public partial interface IDiscoveryService
2525
{
26+
DetailedResponse<ListProjectsResponse> ListProjects();
27+
DetailedResponse<ProjectDetails> CreateProject(string name, string type, DefaultQueryParams defaultQueryParameters = null);
28+
DetailedResponse<ProjectDetails> GetProject(string projectId);
29+
DetailedResponse<ProjectDetails> UpdateProject(string projectId, string name = null);
30+
DetailedResponse<object> DeleteProject(string projectId);
31+
DetailedResponse<ListFieldsResponse> ListFields(string projectId, List<string> collectionIds = null);
2632
DetailedResponse<ListCollectionsResponse> ListCollections(string projectId);
27-
DetailedResponse<CollectionDetails> CreateCollection(string projectId, string name, string description = null, string language = null, List<CollectionEnrichment> enrichments = null);
33+
DetailedResponse<CollectionDetails> CreateCollection(string projectId, string name, string description = null, string language = null, List<CollectionEnrichment> enrichments = null, CollectionDetailsSmartDocumentUnderstanding smartDocumentUnderstanding = null);
2834
DetailedResponse<CollectionDetails> GetCollection(string projectId, string collectionId);
2935
DetailedResponse<CollectionDetails> UpdateCollection(string projectId, string collectionId, string name = null, string description = null, List<CollectionEnrichment> enrichments = null);
3036
DetailedResponse<object> DeleteCollection(string projectId, string collectionId);
31-
DetailedResponse<QueryResponse> Query(string projectId, List<string> collectionIds = null, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List<string> _return = null, long? offset = null, string sort = null, bool? highlight = null, bool? spellingSuggestions = null, QueryLargeTableResults tableResults = null, QueryLargeSuggestedRefinements suggestedRefinements = null, QueryLargePassages passages = null);
37+
DetailedResponse<ListDocumentsResponse> ListDocuments(string projectId, string collectionId, long? count = null, string status = null, bool? hasNotices = null, bool? isParent = null, string parentDocumentId = null, string sha256 = null);
38+
DetailedResponse<DocumentAccepted> AddDocument(string projectId, string collectionId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null, bool? xWatsonDiscoveryForce = null);
39+
DetailedResponse<DocumentDetails> GetDocument(string projectId, string collectionId, string documentId);
40+
DetailedResponse<DocumentAccepted> UpdateDocument(string projectId, string collectionId, string documentId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null, bool? xWatsonDiscoveryForce = null);
41+
DetailedResponse<DeleteDocumentResponse> DeleteDocument(string projectId, string collectionId, string documentId, bool? xWatsonDiscoveryForce = null);
42+
DetailedResponse<QueryResponse> Query(string projectId, List<string> collectionIds = null, string filter = null, string query = null, string naturalLanguageQuery = null, string aggregation = null, long? count = null, List<string> _return = null, long? offset = null, string sort = null, bool? highlight = null, bool? spellingSuggestions = null, QueryLargeTableResults tableResults = null, QueryLargeSuggestedRefinements suggestedRefinements = null, QueryLargePassages passages = null, QueryLargeSimilar similar = null);
3243
DetailedResponse<Completions> GetAutocompletion(string projectId, string prefix, List<string> collectionIds = null, string field = null, long? count = null);
3344
DetailedResponse<QueryNoticesResponse> QueryCollectionNotices(string projectId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, long? count = null, long? offset = null);
3445
DetailedResponse<QueryNoticesResponse> QueryNotices(string projectId, string filter = null, string query = null, string naturalLanguageQuery = null, long? count = null, long? offset = null);
35-
DetailedResponse<ListFieldsResponse> ListFields(string projectId, List<string> collectionIds = null);
46+
DetailedResponse<StopWordList> GetStopwordList(string projectId, string collectionId);
47+
DetailedResponse<StopWordList> CreateStopwordList(string projectId, string collectionId, List<string> stopwords = null);
48+
DetailedResponse<object> DeleteStopwordList(string projectId, string collectionId);
49+
DetailedResponse<Expansions> ListExpansions(string projectId, string collectionId);
50+
DetailedResponse<Expansions> CreateExpansions(string projectId, string collectionId, List<Expansion> expansions);
51+
DetailedResponse<object> DeleteExpansions(string projectId, string collectionId);
3652
DetailedResponse<ComponentSettingsResponse> GetComponentSettings(string projectId);
37-
DetailedResponse<DocumentAccepted> AddDocument(string projectId, string collectionId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null, bool? xWatsonDiscoveryForce = null);
38-
DetailedResponse<DocumentAccepted> UpdateDocument(string projectId, string collectionId, string documentId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null, bool? xWatsonDiscoveryForce = null);
39-
DetailedResponse<DeleteDocumentResponse> DeleteDocument(string projectId, string collectionId, string documentId, bool? xWatsonDiscoveryForce = null);
4053
DetailedResponse<TrainingQuerySet> ListTrainingQueries(string projectId);
4154
DetailedResponse<object> DeleteTrainingQueries(string projectId);
4255
DetailedResponse<TrainingQuery> CreateTrainingQuery(string projectId, string naturalLanguageQuery, List<TrainingExample> examples, string filter = null);
4356
DetailedResponse<TrainingQuery> GetTrainingQuery(string projectId, string queryId);
4457
DetailedResponse<TrainingQuery> UpdateTrainingQuery(string projectId, string queryId, string naturalLanguageQuery, List<TrainingExample> examples, string filter = null);
4558
DetailedResponse<object> DeleteTrainingQuery(string projectId, string queryId);
46-
DetailedResponse<AnalyzedDocument> AnalyzeDocument(string projectId, string collectionId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null);
4759
DetailedResponse<Enrichments> ListEnrichments(string projectId);
4860
DetailedResponse<Enrichment> CreateEnrichment(string projectId, CreateEnrichment enrichment, System.IO.MemoryStream file = null);
4961
DetailedResponse<Enrichment> GetEnrichment(string projectId, string enrichmentId);
5062
DetailedResponse<Enrichment> UpdateEnrichment(string projectId, string enrichmentId, string name, string description = null);
5163
DetailedResponse<object> DeleteEnrichment(string projectId, string enrichmentId);
52-
DetailedResponse<ListProjectsResponse> ListProjects();
53-
DetailedResponse<ProjectDetails> CreateProject(string name, string type, DefaultQueryParams defaultQueryParameters = null);
54-
DetailedResponse<ProjectDetails> GetProject(string projectId);
55-
DetailedResponse<ProjectDetails> UpdateProject(string projectId, string name = null);
56-
DetailedResponse<object> DeleteProject(string projectId);
64+
DetailedResponse<DocumentClassifiers> ListDocumentClassifiers(string projectId);
65+
DetailedResponse<DocumentClassifier> CreateDocumentClassifier(string projectId, System.IO.MemoryStream trainingData, CreateDocumentClassifier classifier, System.IO.MemoryStream testData = null);
66+
DetailedResponse<DocumentClassifier> GetDocumentClassifier(string projectId, string classifierId);
67+
DetailedResponse<DocumentClassifier> UpdateDocumentClassifier(string projectId, string classifierId, UpdateDocumentClassifier classifier, System.IO.MemoryStream trainingData = null, System.IO.MemoryStream testData = null);
68+
DetailedResponse<object> DeleteDocumentClassifier(string projectId, string classifierId);
69+
DetailedResponse<DocumentClassifierModels> ListDocumentClassifierModels(string projectId, string classifierId);
70+
DetailedResponse<DocumentClassifierModel> CreateDocumentClassifierModel(string projectId, string classifierId, string name, string description = null, double? learningRate = null, List<double?> l1RegularizationStrengths = null, List<double?> l2RegularizationStrengths = null, long? trainingMaxSteps = null, double? improvementRatio = null);
71+
DetailedResponse<DocumentClassifierModel> GetDocumentClassifierModel(string projectId, string classifierId, string modelId);
72+
DetailedResponse<DocumentClassifierModel> UpdateDocumentClassifierModel(string projectId, string classifierId, string modelId, string name = null, string description = null);
73+
DetailedResponse<object> DeleteDocumentClassifierModel(string projectId, string classifierId, string modelId);
74+
DetailedResponse<AnalyzedDocument> AnalyzeDocument(string projectId, string collectionId, System.IO.MemoryStream file = null, string filename = null, string fileContentType = null, string metadata = null);
5775
DetailedResponse<object> DeleteUserData(string customerId);
5876
}
5977
}

src/IBM.Watson.Discovery.v2/Model/AnalyzedDocument.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2020, 2021.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,12 +21,13 @@
2121
namespace IBM.Watson.Discovery.v2.Model
2222
{
2323
/// <summary>
24-
/// An object that contains the converted document and any identified enrichments.
24+
/// An object that contains the converted document and any identified enrichments. Root-level fields from the
25+
/// original file are returned also.
2526
/// </summary>
2627
public class AnalyzedDocument
2728
{
2829
/// <summary>
29-
/// Array of document results that match the query.
30+
/// Array of notices that are triggered when the files are processed.
3031
/// </summary>
3132
[JsonProperty("notices", NullValueHandling = NullValueHandling.Ignore)]
3233
public List<Notice> Notices { get; set; }

src/IBM.Watson.Discovery.v2/Model/AnalyzedResult.cs

Lines changed: 2 additions & 2 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");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ namespace IBM.Watson.Discovery.v2.Model
2727
public class AnalyzedResult : DynamicModel<object>
2828
{
2929
/// <summary>
30-
/// Metadata of the document.
30+
/// Metadata that was specified with the request.
3131
/// </summary>
3232
[JsonProperty("metadata", NullValueHandling = NullValueHandling.Ignore)]
3333
public Dictionary<string, object> Metadata { get; set; }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.Discovery.v2.Model
21+
{
22+
/// <summary>
23+
/// An object with details for creating federated document classifier models.
24+
/// </summary>
25+
public class ClassifierFederatedModel
26+
{
27+
/// <summary>
28+
/// Name of the field that contains the values from which multiple classifier models are defined. For example,
29+
/// you can specify a field that lists product lines to create a separate model per product line.
30+
/// </summary>
31+
[JsonProperty("field", NullValueHandling = NullValueHandling.Ignore)]
32+
public string Field { get; set; }
33+
}
34+
35+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using System.Collections.Generic;
19+
using Newtonsoft.Json;
20+
21+
namespace IBM.Watson.Discovery.v2.Model
22+
{
23+
/// <summary>
24+
/// An object that contains information about a trained document classifier model.
25+
/// </summary>
26+
public class ClassifierModelEvaluation
27+
{
28+
/// <summary>
29+
/// A micro-average aggregates the contributions of all classes to compute the average metric. Classes refers to
30+
/// the classification labels that are specified in the **answer_field**.
31+
/// </summary>
32+
[JsonProperty("micro_average", NullValueHandling = NullValueHandling.Ignore)]
33+
public ModelEvaluationMicroAverage MicroAverage { get; set; }
34+
/// <summary>
35+
/// A macro-average computes metric independently for each class and then takes the average. Class refers to the
36+
/// classification label that is specified in the **answer_field**.
37+
/// </summary>
38+
[JsonProperty("macro_average", NullValueHandling = NullValueHandling.Ignore)]
39+
public ModelEvaluationMacroAverage MacroAverage { get; set; }
40+
/// <summary>
41+
/// An array of evaluation metrics, one set of metrics for each class, where class refers to the classification
42+
/// label that is specified in the **answer_field**.
43+
/// </summary>
44+
[JsonProperty("per_class", NullValueHandling = NullValueHandling.Ignore)]
45+
public List<PerClassModelEvaluation> PerClass { get; set; }
46+
}
47+
48+
}

src/IBM.Watson.Discovery.v2/Model/CollectionDetails.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2018, 2020.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,15 +47,26 @@ public class CollectionDetails
4747
[JsonProperty("created", NullValueHandling = NullValueHandling.Ignore)]
4848
public virtual DateTime? Created { get; private set; }
4949
/// <summary>
50-
/// The language of the collection.
50+
/// The language of the collection. For a list of supported languages, see the [product
51+
/// documentation](/docs/discovery-data?topic=discovery-data-language-support).
5152
/// </summary>
5253
[JsonProperty("language", NullValueHandling = NullValueHandling.Ignore)]
5354
public string Language { get; set; }
5455
/// <summary>
55-
/// An array of enrichments that are applied to this collection.
56+
/// An array of enrichments that are applied to this collection. To get a list of enrichments that are available
57+
/// for a project, use the [List enrichments](#listenrichments) method.
58+
///
59+
/// If no enrichments are specified when the collection is created, the default enrichments for the project type
60+
/// are applied. For more information about project default settings, see the [product
61+
/// documentation](/docs/discovery-data?topic=discovery-data-project-defaults).
5662
/// </summary>
5763
[JsonProperty("enrichments", NullValueHandling = NullValueHandling.Ignore)]
5864
public List<CollectionEnrichment> Enrichments { get; set; }
65+
/// <summary>
66+
/// An object that describes the Smart Document Understanding model for a collection.
67+
/// </summary>
68+
[JsonProperty("smart_document_understanding", NullValueHandling = NullValueHandling.Ignore)]
69+
public CollectionDetailsSmartDocumentUnderstanding SmartDocumentUnderstanding { get; set; }
5970
}
6071

6172
}

0 commit comments

Comments
 (0)