Skip to contents

Creates a comparison level based on the Soundex phonetic algorithm. Two strings match if their Soundex codes are identical. This can be used as a fallback level within cl_levels() or cl_name() to catch names that sound similar but are spelled differently (e.g., Smith/Smyth, Robert/Rupert).

Usage

cl_soundex()

Value

A comparison-level object for use in il_compare() or cl_levels().

Details

On DuckDB, Soundex runs via a registered SQL MACRO. On PostgreSQL, it uses the native soundex() function. On SQLite, it falls back to an R-side implementation.

Examples

il_spec() |>
  il_compare(first_name, cl_soundex())
#> Linkage Specification
#>   Comparisons (1):
#>     first_name : soundex
#>   Blocking rules: (none)

il_spec() |>
  il_compare(
    first_name,
    cl_levels(
      cl_null(),
      cl_exact(),
      cl_jaro_winkler(0.9),
      cl_soundex(),
      cl_else()
    )
  )
#> Linkage Specification
#>   Comparisons (1):
#>     first_name : levels
#>   Blocking rules: (none)