共用方式為


TextAnalysisClient.AnalyzeText Method

Definition

Overloads

AnalyzeText(AnalyzeTextInput, Nullable<Boolean>, CancellationToken)

Request text analysis over a collection of documents.

AnalyzeText(RequestContent, Nullable<Boolean>, RequestContext)

[Protocol Method] Request text analysis over a collection of documents.

AnalyzeText(AnalyzeTextInput, Nullable<Boolean>, CancellationToken)

Source:
TextAnalysisClient.cs

Request text analysis over a collection of documents.

public virtual Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult> AnalyzeText (Azure.AI.Language.Text.AnalyzeTextInput analyzeTextInput, bool? showStatistics = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AnalyzeText : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>
override this.AnalyzeText : Azure.AI.Language.Text.AnalyzeTextInput * Nullable<bool> * System.Threading.CancellationToken -> Azure.Response<Azure.AI.Language.Text.AnalyzeTextResult>
Public Overridable Function AnalyzeText (analyzeTextInput As AnalyzeTextInput, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AnalyzeTextResult)

Parameters

analyzeTextInput
AnalyzeTextInput

The input documents to analyze.

showStatistics
Nullable<Boolean>

(Optional) if set to true, response will contain request and document level statistics.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

analyzeTextInput is null.

Examples

This sample shows how to call AnalyzeText.

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

AnalyzeTextInput analyzeTextInput = new TextDynamicClassificationInput();
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput);

This sample shows how to call AnalyzeText with all parameters.

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

AnalyzeTextInput analyzeTextInput = new TextDynamicClassificationInput
{
    TextInput = new MultiLanguageTextInput
    {
        MultiLanguageInputs = {new MultiLanguageInput("<id>", "<text>")
        {
            Language = "<language>",
        }},
    },
    ActionContent = new DynamicClassificationActionContent(new string[] { "<categories>" })
    {
        LoggingOptOut = true,
        ModelVersion = "<modelVersion>",
        ClassificationType = ClassificationType.Multi,
    },
};
Response<AnalyzeTextResult> response = client.AnalyzeText(analyzeTextInput, showStatistics: true);

Applies to

AnalyzeText(RequestContent, Nullable<Boolean>, RequestContext)

Source:
TextAnalysisClient.cs

[Protocol Method] Request text analysis over a collection of documents.

public virtual Azure.Response AnalyzeText (Azure.Core.RequestContent content, bool? showStatistics = default, Azure.RequestContext context = default);
abstract member AnalyzeText : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> Azure.Response
override this.AnalyzeText : Azure.Core.RequestContent * Nullable<bool> * Azure.RequestContext -> Azure.Response
Public Overridable Function AnalyzeText (content As RequestContent, Optional showStatistics As Nullable(Of Boolean) = Nothing, Optional context As RequestContext = Nothing) As Response

Parameters

content
RequestContent

The content to send as the body of the request.

showStatistics
Nullable<Boolean>

(Optional) if set to true, response will contain request and document level statistics.

context
RequestContext

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

Returns

The response returned from the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

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

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

using RequestContent content = RequestContent.Create(new
{
    kind = "DynamicClassification",
});
Response response = client.AnalyzeText(content);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

This sample shows how to call AnalyzeText with all parameters and request content and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    kind = "DynamicClassification",
    analysisInput = new
    {
        documents = new object[]
        {
            new
            {
                id = "<id>",
                text = "<text>",
                language = "<language>",
            }
        },
    },
    parameters = new
    {
        loggingOptOut = true,
        modelVersion = "<modelVersion>",
        classificationType = "Multi",
        categories = new object[]
        {
            "<categories>"
        },
    },
});
Response response = client.AnalyzeText(content, showStatistics: true);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("kind").ToString());

Applies to