共用方式為


TextAnalyticsClient.DetectLanguage(String, String, CancellationToken) Method

Definition

Runs a predictive model to determine the language the passed-in document is written in, and returns the detected language as well as a score indicating the model's confidence that the inferred language is correct. Scores close to 1 indicate high certainty in the result.

For document length limits, maximum batch size, and supported text encoding, see https://aka.ms/azsdk/textanalytics/data-limits.

public virtual Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage> DetectLanguage (string document, string countryHint = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DetectLanguage : string * string * System.Threading.CancellationToken -> Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage>
override this.DetectLanguage : string * string * System.Threading.CancellationToken -> Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage>
Public Overridable Function DetectLanguage (document As String, Optional countryHint As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Response(Of DetectedLanguage)

Parameters

document
String

The document to analyze.

countryHint
String

Indicates the country of origin of the document to assist the model in predicting the language it is written in. If unspecified, this value will be set to the default country hint in DefaultCountryHint in the request sent to the service. To remove this behavior, set to None.

cancellationToken
CancellationToken

A CancellationToken controlling the request lifetime.

Returns

A result containing the detected language or an error if the model could not analyze the document.

Exceptions

Service returned a non-success status code.

Applies to