Share via


TextAnalyticsClient.DetectLanguageAsync 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 System.Threading.Tasks.Task<Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage>> DetectLanguageAsync (string document, string countryHint = default, System.Threading.CancellationToken cancellationToken = default);
abstract member DetectLanguageAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage>>
override this.DetectLanguageAsync : string * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.AI.TextAnalytics.DetectedLanguage>>
Public Overridable Function DetectLanguageAsync (document As String, Optional countryHint As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of 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