Given a single input string and multiple candidates, compute scores for each candidate.

lev_score_multiple(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 list where the keys are candidates and the values are the scores. The list is sorted according to the decreasing parameter, so by default higher scores are first.

See also

Examples

lev_score_multiple("bilbo", c("frodo", "gandalf", "legolas"))
#> $frodo
#> [1] 0.2
#> 
#> $legolas
#> [1] 0.1428571
#> 
#> $gandalf
#> [1] 0
#>