Learn R Programming

fuzzywuzzyR (version 1.0.5)

GetCloseMatches: Matches of character strings

Description

Matches of character strings

Usage

GetCloseMatches(string = NULL, sequence_strings = NULL, n = 3L, cutoff = 0.6)

Arguments

string

a character string.

sequence_strings

a vector of character strings.

n

an integer value specifying the maximum number of close matches to return; n must be greater than 0.

cutoff

a float number in the range [0, 1], sequence_strings that don't score at least that similar to string are ignored.

Details

Returns a list of the best "good enough" matches. string is a sequence for which close matches are desired (typically a string), and sequence_strings is a list of sequences against which to match string (typically a list of strings).

References

https://www.npmjs.com/package/difflib, http://stackoverflow.com/questions/10383044/fuzzy-string-comparison

Examples

Run this code
# NOT RUN {
try({
  if (reticulate::py_available(initialize = FALSE)) {

    if (check_availability()) {

      library(fuzzywuzzyR)

      vec = c('Frodo Baggins', 'Tom Sawyer', 'Bilbo Baggin')

      str1 = 'Fra Bagg'

      GetCloseMatches(string = str1, sequence_strings = vec, n = 2L, cutoff = 0.6)

    }
  }
}, silent=TRUE)
# }

Run the code above in your browser using DataLab