Skip to contents

The comparator used for the first_name field. Plain Jaro-Winkler is a poor fit for given names in two ways: it misses nickname pairs (BOB vs ROBERT score low) and it rarely drops below ~0.5 for unrelated names (so a genuinely different first name adds little discriminating penalty). This comparator fixes both:

  • exact match -> 1;

  • nickname/diminutive of the same canonical (nickname_table()) -> 0.95;

  • single initial vs full name -> 0.6 if the initial agrees, else 0 (an initial is weak evidence, neither a match nor a strong mismatch);

  • otherwise Jaro-Winkler rescaled by (jw - floor) / (1 - floor) so unrelated names fall toward 0 and actually penalise, with a Soundex agreement raising the result to at least 0.5 (a sound-alike is not penalised, but – because Soundex over-collapses – is not asserted as a match either).

Usage

compare_first_names(a, b, floor = 0.5)

Arguments

a, b

Character vectors of equal length.

floor

JW rescaling floor (default 0.5).

Value

Numeric vector of similarities in [0, 1]; NA where a name is missing.

Examples

compare_first_names(c("BOB", "ALEXIS", "JON"), c("ROBERT", "MARCELLA", "JONATHAN"))
#> [1] 0.95000000 0.05555556 0.95000000