Learn R Programming

spell.replacer (version 1.0.1)

correct: Correct a Single Misspelled Word

Description

Finds the best correction for a single misspelled word using string distance and frequency-based ranking from a sorted word list.

Usage

correct(word, sorted_words, ignore_punct = FALSE, threshold = 0.12)

Value

A character string with the corrected word

Arguments

word

A character string representing the misspelled word

sorted_words

A character vector of correctly spelled words sorted by frequency

ignore_punct

Logical. If TRUE, ignores punctuation when calculating string distance

threshold

Numeric. Maximum string distance threshold for considering a word as a correction candidate