Condividi tramite


DocumentIntelligenceAdministrationClient.BuildClassifier Method

Definition

Overloads

BuildClassifier(WaitUntil, BuildDocumentClassifierContent, CancellationToken)

Builds a custom document classifier.

BuildClassifier(WaitUntil, RequestContent, RequestContext)

[Protocol Method] Builds a custom document classifier.

BuildClassifier(WaitUntil, BuildClassifierOptions, CancellationToken)

Builds a custom document classifier.

BuildClassifier(WaitUntil, BuildDocumentClassifierContent, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Builds a custom document classifier.

public virtual Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails> BuildClassifier (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent buildRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
override this.BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildDocumentClassifierContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
Public Overridable Function BuildClassifier (waitUntil As WaitUntil, buildRequest As BuildDocumentClassifierContent, Optional cancellationToken As CancellationToken = Nothing) As Operation(Of DocumentClassifierDetails)

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

buildRequest
BuildDocumentClassifierContent

Build request parameters.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

buildRequest is null.

Examples

This sample shows how to call BuildClassifier.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

BuildDocumentClassifierContent buildRequest = new BuildDocumentClassifierContent("<classifierId>", new Dictionary<string, ClassifierDocumentTypeDetails>
{
    ["key"] = new ClassifierDocumentTypeDetails()
});
Operation<DocumentClassifierDetails> operation = client.BuildClassifier(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;

This sample shows how to call BuildClassifier with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

BuildDocumentClassifierContent buildRequest = new BuildDocumentClassifierContent("<classifierId>", new Dictionary<string, ClassifierDocumentTypeDetails>
{
    ["key"] = new ClassifierDocumentTypeDetails
    {
        SourceKind = ContentSourceKind.Url,
        AzureBlobSource = new AzureBlobContentSource(new Uri("http://localhost:3000"))
        {
            Prefix = "<prefix>",
        },
        AzureBlobFileListSource = new AzureBlobFileListContentSource(new Uri("http://localhost:3000"), "<fileList>"),
    }
})
{
    Description = "<description>",
    BaseClassifierId = "<baseClassifierId>",
    AllowOverwrite = true,
};
Operation<DocumentClassifierDetails> operation = client.BuildClassifier(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;

Applies to

BuildClassifier(WaitUntil, RequestContent, RequestContext)

Source:
DocumentIntelligenceAdministrationClient.cs
Source:
DocumentIntelligenceAdministrationClient.cs

[Protocol Method] Builds a custom document classifier.

public virtual Azure.Operation<BinaryData> BuildClassifier (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member BuildClassifier : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.BuildClassifier : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function BuildClassifier (waitUntil As WaitUntil, content As RequestContent, Optional context As RequestContext = Nothing) As Operation(Of BinaryData)

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call BuildClassifier and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    classifierId = "myClassifier",
    description = "Classifier description",
    docTypes = new
    {
        formA = new
        {
            azureBlobSource = new
            {
                containerUrl = "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
                prefix = "formADocs/",
            },
        },
        formB = new
        {
            azureBlobFileListSource = new
            {
                containerUrl = "https://myStorageAccount.blob.core.windows.net/myContainer?mySasToken",
                fileList = "formB.jsonl",
            },
        },
    },
});
Operation<BinaryData> operation = client.BuildClassifier(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").ToString());

Applies to

BuildClassifier(WaitUntil, BuildClassifierOptions, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Builds a custom document classifier.

public virtual Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails> BuildClassifier (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.BuildClassifierOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildClassifierOptions * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
override this.BuildClassifier : Azure.WaitUntil * Azure.AI.DocumentIntelligence.BuildClassifierOptions * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentClassifierDetails>
Public Overridable Function BuildClassifier (waitUntil As WaitUntil, options As BuildClassifierOptions, Optional cancellationToken As CancellationToken = Nothing) As Operation(Of DocumentClassifierDetails)

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

options
BuildClassifierOptions

Build request options.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call BuildClassifier.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

BuildClassifierOptions buildRequest = new BuildClassifierOptions("myClassifier", new Dictionary<string, ClassifierDocumentTypeDetails>
{
    ["formA"] = new ClassifierDocumentTypeDetails(),
    ["formB"] = new ClassifierDocumentTypeDetails()
})
{
    Description = "Classifier description",
};
Operation<DocumentClassifierDetails> operation = client.BuildClassifier(WaitUntil.Completed, buildRequest);
DocumentClassifierDetails responseData = operation.Value;

Applies to