Learn R Programming

FastUtils (version 0.2.1)

closestWord: Find the Closest Word in a Set to a Given Word

Description

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)

Value

The closest word in the set to the given word.

Arguments

s

A character string.

strset

A set of character strings.

distFunc

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

Examples

Run this code
# Find the closest word to "hello" in the set c("hallo", "hullo", "hey")
closestWord("hello", c("hallo", "hullo", "hey"))

Run the code above in your browser using DataLab