lev_weighted_token_ratio | R Documentation |
Computes similarity but allows you to assign weights to specific tokens. This is useful, for example, when you have a frequently-occurring string that doesn't contain useful information. See examples.
lev_weighted_token_ratio(a, b, weights = list(), ...)
a, b |
The input strings |
weights |
List of token weights. For example, |
... |
Additional arguments to be passed to |
A float
The algorithm used here is as follows:
Tokenise the input strings
Compute the edit distance between each pair of tokens
Compute the maximum edit distance between each pair of tokens
Apply any weights from the weights
argument
Return 1 - (sum(weighted_edit_distances) / sum(weighted_max_edit_distance))
Other weighted token functions:
lev_weighted_token_set_ratio()
,
lev_weighted_token_sort_ratio()
lev_weighted_token_ratio("jim ltd", "tim ltd")
lev_weighted_token_ratio("tim ltd", "jim ltd", weights = list(ltd = 0.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.