Table of Contents

Method DetectLanguageAsync

Namespace
LMKit.Translation
Assembly
LM-Kit.NET.dll

DetectLanguageAsync(string, IEnumerable<Language>, CancellationToken)

Detects the language of a specified plain text.

public Task<Language> DetectLanguageAsync(string text, IEnumerable<Language> languages = null, CancellationToken cancellationToken = default)

Parameters

text string

The text for which to detect the language.

languages IEnumerable<Language>

An optional collection of languages to consider during the operation. If omitted, the method defaults to utilizing the full range of languages specified within the Language enumeration, thus encompassing all supported languages.

cancellationToken CancellationToken

Optional. A CancellationToken for handling cancellation requests.

Returns

Task<Language>

The detected language as a member of the Language enumeration. If the language cannot be determined, the Language.Undefined member will be returned.

Remarks

This method analyzes the text content and identifies its language, supporting both single and multiline texts with various formatting.
It leverages various language detection algorithms to determine the language from a set of possible languages.