Partager via


DocumentIntelligenceClient.ClassifyDocument Method

Definition

Overloads

ClassifyDocument(WaitUntil, ClassifyDocumentOptions, CancellationToken)

Classifies document with document classifier.

ClassifyDocument(WaitUntil, String, ClassifyDocumentContent, Nullable<StringIndexType>, Nullable<SplitMode>, String, CancellationToken)

Classifies document with document classifier.

ClassifyDocument(WaitUntil, String, RequestContent, String, String, String, RequestContext)

[Protocol Method] Classifies document with document classifier.

ClassifyDocument(WaitUntil, ClassifyDocumentOptions, CancellationToken)

Source:
DocumentIntelligenceClient.cs

Classifies document with document classifier.

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

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
ClassifyDocumentOptions

Classify request options.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call ClassifyDocument.

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

ClassifyDocumentOptions classifyRequest = new ClassifyDocumentOptions
{
    UriSource = new Uri("http://host.com/doc.pdf"),
};
Operation<AnalyzeResult> operation = client.ClassifyDocument(WaitUntil.Completed, "classifierId", classifyRequest);
AnalyzeResult responseData = operation.Value;

Applies to

ClassifyDocument(WaitUntil, String, ClassifyDocumentContent, Nullable<StringIndexType>, Nullable<SplitMode>, String, CancellationToken)

Source:
DocumentIntelligenceClient.cs

Classifies document with document classifier.

public virtual Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult> ClassifyDocument (Azure.WaitUntil waitUntil, string classifierId, Azure.AI.DocumentIntelligence.ClassifyDocumentContent classifyRequest, Azure.AI.DocumentIntelligence.StringIndexType? stringIndexType = default, Azure.AI.DocumentIntelligence.SplitMode? split = default, string pages = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ClassifyDocument : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.ClassifyDocumentContent * Nullable<Azure.AI.DocumentIntelligence.StringIndexType> * Nullable<Azure.AI.DocumentIntelligence.SplitMode> * string * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>
override this.ClassifyDocument : Azure.WaitUntil * string * Azure.AI.DocumentIntelligence.ClassifyDocumentContent * Nullable<Azure.AI.DocumentIntelligence.StringIndexType> * Nullable<Azure.AI.DocumentIntelligence.SplitMode> * string * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.AnalyzeResult>
Public Overridable Function ClassifyDocument (waitUntil As WaitUntil, classifierId As String, classifyRequest As ClassifyDocumentContent, Optional stringIndexType As Nullable(Of StringIndexType) = Nothing, Optional split As Nullable(Of SplitMode) = Nothing, Optional pages As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Operation(Of AnalyzeResult)

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.

classifierId
String

Unique document classifier name.

classifyRequest
ClassifyDocumentContent

Classify request parameters.

stringIndexType
Nullable<StringIndexType>

Method used to compute string offset and length.

split
Nullable<SplitMode>

Document splitting mode.

pages
String

List of 1-based page numbers to analyze. Ex. "1-3,5,7-9".

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

classifierId or classifyRequest is null.

classifierId is an empty string, and was expected to be non-empty.

Examples

This sample shows how to call ClassifyDocument.

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

ClassifyDocumentContent classifyRequest = new ClassifyDocumentContent();
Operation<AnalyzeResult> operation = client.ClassifyDocument(WaitUntil.Completed, "<classifierId>", classifyRequest);
AnalyzeResult responseData = operation.Value;

This sample shows how to call ClassifyDocument with all parameters.

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

ClassifyDocumentContent classifyRequest = new ClassifyDocumentContent
{
    UrlSource = new Uri("http://localhost:3000"),
    Base64Source = BinaryData.FromObjectAsJson(new object()),
};
Operation<AnalyzeResult> operation = client.ClassifyDocument(WaitUntil.Completed, "<classifierId>", classifyRequest, stringIndexType: StringIndexType.TextElements, split: SplitMode.Auto, pages: "<pages>");
AnalyzeResult responseData = operation.Value;

Applies to

ClassifyDocument(WaitUntil, String, RequestContent, String, String, String, RequestContext)

Source:
DocumentIntelligenceClient.cs
Source:
DocumentIntelligenceClient.cs

[Protocol Method] Classifies document with document classifier.

public virtual Azure.Operation<BinaryData> ClassifyDocument (Azure.WaitUntil waitUntil, string classifierId, Azure.Core.RequestContent content, string stringIndexType = default, string split = default, string pages = default, Azure.RequestContext context = default);
abstract member ClassifyDocument : Azure.WaitUntil * string * Azure.Core.RequestContent * string * string * string * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.ClassifyDocument : Azure.WaitUntil * string * Azure.Core.RequestContent * string * string * string * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function ClassifyDocument (waitUntil As WaitUntil, classifierId As String, content As RequestContent, Optional stringIndexType As String = Nothing, Optional split As String = Nothing, Optional pages As String = Nothing, 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.

classifierId
String

Unique document classifier name.

content
RequestContent

The content to send as the body of the request.

stringIndexType
String

Method used to compute string offset and length. Allowed values: "textElements" | "unicodeCodePoint" | "utf16CodeUnit".

split
String

Document splitting mode. Allowed values: "auto" | "none" | "perPage".

pages
String

1-based page numbers to analyze. Ex. "1-3,5,7-9".

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

classifierId or content is null.

classifierId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

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

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

using RequestContent content = RequestContent.Create(new
{
    urlSource = "http://host.com/doc.pdf",
});
Operation<BinaryData> operation = client.ClassifyDocument(WaitUntil.Completed, "classifierId", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("stringIndexType").ToString());
Console.WriteLine(result.GetProperty("content").ToString());
Console.WriteLine(result.GetProperty("pages")[0].GetProperty("pageNumber").ToString());
Console.WriteLine(result.GetProperty("pages")[0].GetProperty("spans")[0].GetProperty("offset").ToString());
Console.WriteLine(result.GetProperty("pages")[0].GetProperty("spans")[0].GetProperty("length").ToString());

Applies to