lev_best_match: Get the best matched string from a list of candidates

View source: R/ranking.R

lev_best_matchR Documentation

Get the best matched string from a list of candidates

Description

Given an input string and multiple candidates, return the candidate with the best score as calculated by .fn.

Usage

lev_best_match(input, candidates, .fn = lev_ratio, ..., decreasing = TRUE)

Arguments

input

A single string

candidates

One or more candidate strings to score

.fn

The scoring function to use, as a string or function object. Defaults to lev_ratio().

...

Additional arguments to pass to .fn.

decreasing

If TRUE (the default), the candidate with the highest score is ranked first. If using a comparison .fn that computes distance rather than similarity, or if you want the worst match to be returned first, set this to FALSE.

Value

A string

See Also

lev_score_multiple()

Examples

lev_best_match("bilbo", c("frodo", "gandalf", "legolas"))

levitate documentation built on Oct. 1, 2023, 1:08 a.m.