Correct(text)
Synchronous correction returning the cleaned string.
The TextCorrection engine fixes grammar, spelling,
subject-verb agreement, tense errors, and stylistic inconsistencies in
any language the underlying model supports. Sync and async APIs,
streaming completion events for live editing UIs, and zero cloud calls
so user keystrokes never leave the machine.
Correct(text)Synchronous correction returning the cleaned string.
CorrectAsync(text, ct)Async with cancellation for typing-aware UIs.
AfterTextCompletionEvent with each generated chunk for streaming display.
TextCorrection is a generative corrector, not a rule engine.
It catches mistakes that simple spellcheckers miss because it understands
context: homophones, agreement, subordinate clauses, register, ambiguous
pronouns. The output is the corrected text, not a list of suggestions, so
you ship clean strings to the user instead of a dialog tree.
Catches misspellings even when they form valid words ("there/their/they're", "your/you're"). Context-aware, not dictionary-only.
"The list of items are long" becomes "The list of items is long". Resolves agreement across long subordinate clauses that confuse rule engines.
Aligns verb tenses across compound sentences. "He went to the store and buys milk" becomes "He went to the store and bought milk".
Restores missing periods, commas, capital letters, and apostrophes. Handles dictation outputs that arrive without proper formatting.
Reorders awkward phrasings produced by non-native speakers, dictation systems, or machine translation post-editing.
Works in every language supported by the underlying model. Same API, same call, automatic language detection from input.
using LMKit.Model; using LMKit.TextEnhancement; var model = LM.LoadFromModelID("qwen3.5:4b"); var corrector = new TextCorrection(model); string input = "My cat dont never flyed to the moon because he too tired."; string corrected = corrector.Correct(input); Console.WriteLine(corrected); // "My cat has never flown to the moon because he was too tired."
using System.Threading; using LMKit.TextEnhancement; var corrector = new TextCorrection(model); CancellationTokenSource cts = null; async Task OnTextChanged(string editorText) { // Cancel any in-flight correction; we only want the latest. cts?.Cancel(); cts = new CancellationTokenSource(); try { string fixedText = await corrector.CorrectAsync(editorText, cts.Token); UpdateGutter(fixedText); } catch (OperationCanceledException) { /* user kept typing */ } }
using LMKit.TextEnhancement; var corrector = new TextCorrection(model); // Stream tokens as they're produced for a live preview. corrector.AfterTextCompletion += (sender, e) => { Console.Write(e.Text); }; string draft = await File.ReadAllTextAsync("draft.md"); await corrector.CorrectAsync(draft);
Catch mistakes before send without uploading every draft to a cloud service. Critical for HIPAA and GDPR-bound communications.
Pair with SpeechToText to clean up raw transcripts: punctuation, capitalisation, agreement.
Run after TextTranslation to smooth out machine-translated artefacts before publishing.
Auto-correct user-entered free-text fields before they reach the backend. Reduces downstream parsing errors.
Polish reply drafts without sending customer data to third-party grammar tools. Keep PII inside the perimeter.
Embed correction directly in writing apps, IDEs, and CMS editors. Real-time suggestions without a cloud round-trip.
TextCorrectionSealed class. Construct with an LM, call Correct / CorrectAsync, optionally subscribe to AfterTextCompletion for streaming.
AfterTextCompletionEvent raised on each token chunk during async correction. Use to drive live UI updates and progress indicators.
TextRewriterCompanion class for stylistic transformation. Use after TextCorrection to also adjust tone, formality, or voice.
Working console demos on GitHub, step-by-step how-to guides on the docs site, and the API reference for the classes used on this page.