Skip to contents

Returns the maximum of two views, which together are robust to the two ways a parser mangles a surname without changing the person:

whole-string

Jaro-Winkler on the names with all separators removed. Rescues separator noise where token splitting fails — "MCLANE" vs "MC-LANE" collapse to the same string (1.0), and "VANDERBERG" vs "VAN DER BERG" likewise.

coverage token-match

Greedy one-to-one Jaro-Winkler matching of the tokens, summing matched similarities and dividing by the smaller token count. Rescues a dropped or reordered token — "ANDREWS-MCLANE" vs "MCLANE" is 1.0 because the shorter name is fully covered — while penalising two different multi-token surnames that merely share one token: "WEINER-COHEN" vs "COHEN-GANTSOUDES" scores low, not 1.0.

The earlier "best single token" rule returned 1.0 for the latter case, letting two different people who share one surname token look identical; dividing by the smaller token count is what closes that leak.

Usage

compare_two_names(x, y, floor = 0.8, rescale = 0.5)

Arguments

x, y

Single character strings (each may be compound/hyphenated).

floor

Minimum token-pair similarity counted as a match in the coverage view.

rescale

Lower anchor for the final rescaling; similarities at or below it map to 0.

Value

A similarity in [0, 1] (1 = identical); NA_real_ if either name is missing or empty.

Details

The max of the two views is finally rescaled by (v - rescale) / (1 - rescale) so that unrelated surnames (Jaro-Winkler rarely drops below ~0.5) land near 0 and penalise in scoring, instead of reading as "half a match".

Examples

compare_two_names("ANDREWS-MCLANE", "MCLANE")        # dropped token -> ~1
#> [1] 1
compare_two_names("WEINER-COHEN", "COHEN-GANTSOUDES") # shared token only -> low
#> [1] 0.06868687