Skip to contents

This function finds the closest word in a set of words to a given word based on a specified distance function.

Usage

closestWord(s, strset, distFunc = utils::adist)

Arguments

s

A character string.

strset

A set of character strings.

distFunc

A function to compute distance between strings. Default is utils::adist.

Value

The closest word in the set to the given word.

Examples

# Find the closest word to "hello" in the set c("hallo", "hullo", "hey")
closestWord("hello", c("hallo", "hullo", "hey"))
#> [1] "hallo"