Table of Contents

Method ExtractKeywords

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

ExtractKeywords(string, CancellationToken)

Extracts a set of keywords synchronously from the given text content.

public List<KeywordExtraction.KeywordItem> ExtractKeywords(string content, CancellationToken cancellationToken = default)

Parameters

content string

The text content from which to extract keywords.

cancellationToken CancellationToken

A token to cancel the operation if needed.

Returns

List<KeywordExtraction.KeywordItem>

A list of extracted KeywordExtraction.KeywordItem instances.

Examples

var keywords = extractor.ExtractKeywords("This is some example content about cars and trucks.");
foreach (var keyword in keywords)
{
    Console.WriteLine(keyword.Value);
}

Exceptions

ArgumentNullException

Thrown when the content is null or empty.

ExtractKeywords(Attachment, CancellationToken)

Extracts a set of keywords synchronously from an image provided as an Attachment.

public List<KeywordExtraction.KeywordItem> ExtractKeywords(Attachment content, CancellationToken cancellationToken = default)

Parameters

content Attachment

The attachment representing the image from which to extract keywords.

cancellationToken CancellationToken

A token to cancel the operation if needed.

Returns

List<KeywordExtraction.KeywordItem>

A list of extracted KeywordExtraction.KeywordItem instances.

Examples

// Synchronous extraction from an image attachment
var keywords = extractor.ExtractKeywords(imageAttachment);
foreach (var keyword in keywords)
{
    Console.WriteLine(keyword.Value);
}

Exceptions

ArgumentNullException

Thrown when the attachment is null.

InvalidModelException

Thrown when the underlying language model does not support vision input, which is required to analyze image attachments.