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
stringThe plain text that needs to be classified.
normalize
boolOptional. Specifies whether input parameters normalization should be enabled. Default is true.
cancellationToken
CancellationTokenOptional. A CancellationToken for handling cancellation requests.
Returns
- int
The index within the
categories
list that best matches the category associated with thecandidate
text. Returns -1 if no category can be associated.
Exceptions
- OperationCanceledException
Thrown if the operation is cancelled via the
cancellationToken
.