Table of Contents

Method GetBestCategory

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

GetBestCategory(IList<string>, string, bool, CancellationToken)

Classifies a given text into one of the predefined categories.

public int GetBestCategory(IList<string> categories, string candidate, bool normalize = true, CancellationToken cancellationToken = default)

Parameters

categories IList<string>

A list of predefined categories. Each entry should be a description of its corresponding category.

candidate string

The plain text that needs to be classified.

normalize bool

Optional. Specifies whether input parameters normalization should be enabled. Default is true.

cancellationToken CancellationToken

Optional. A CancellationToken for handling cancellation requests.

Returns

int

The index within the categories list that best matches the category associated with the candidate text. Returns -1 if no category can be associated.

Exceptions

OperationCanceledException

Thrown if the operation is cancelled via the cancellationToken.