Table of Contents

Method Rewrite

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

Rewrite(string, CommunicationStyle, Language, CancellationToken)

Rewrites the specified text into a specified style and language.

public string Rewrite(string text, TextRewriter.CommunicationStyle style, Language language = Language.English, CancellationToken cancellationToken = default)

Parameters

text string

The text to rewrite; cannot be null or whitespace.

style TextRewriter.CommunicationStyle

The communication style to apply.

language Language

The language for the rewritten text. Default is English.

cancellationToken CancellationToken

Optional. A CancellationToken for handling cancellation requests.

Returns

string

The rewritten text.

Examples

using LMKit.TextEnhancement;
using LMKit.Model;

// Initialize the language model (LLM)
LLM languageModel = new LLM("path/to/your/model");

// Create an instance of TextRewriter using the LLM
TextRewriter textRewriter = new TextRewriter(languageModel);

// Text to rewrite
string text = "Hey, what's up? I'm looking to get in touch with HR.";

// Rewrite the text in a professional style
string rewrittenText = textRewriter.Rewrite(text, CommunicationStyle.Professional);

Console.WriteLine(rewrittenText);
// Output: "Hello, I would like to get in touch with the HR department."

Remarks

This method handles text of any size, preserving the structure and formatting of the original content.

Exceptions

ArgumentException

Thrown if the input text is null or whitespace.