Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Phonetic Functions

Phonetic encoding functions for sound-based string matching.

Summary

FunctionSignatureDescription
caverphonestring -> stringCaverphone code
caverphone2string -> stringCaverphone 2 code
double_metaphonestring -> objectDouble Metaphone codes
match_rating_codexstring -> stringMatch Rating codex
metaphonestring -> stringMetaphone phonetic code
nysiisstring -> stringNYSIIS phonetic code
phonetic_matchstring, string, string -> booleanCheck phonetic match with algorithm
soundexstring -> stringSoundex phonetic code
sounds_likestring, string -> booleanCheck if strings sound similar

Functions

caverphone

Caverphone code

Signature: string -> string

Examples:

# Common name
caverphone('Smith') -> \"SMT1111111\"
# Another name
caverphone('Thompson') -> \"TMPSN11111\"

CLI Usage:

echo '{}' | jpx 'caverphone(`"Smith"`)'

caverphone2

Caverphone 2 code

Signature: string -> string

Examples:

# Common name
caverphone2('Smith') -> \"SMT1111111\"
# Another name
caverphone2('Thompson') -> \"TMPSN11111\"

CLI Usage:

echo '{}' | jpx 'caverphone2(`"Smith"`)'

double_metaphone

Double Metaphone codes

Signature: string -> object

Examples:

# Common name
double_metaphone('Smith') -> {primary: 'SM0', secondary: 'XMT'}
# German variant
double_metaphone('Schmidt') -> {primary: 'XMT', secondary: 'SMT'}

CLI Usage:

echo '{}' | jpx 'double_metaphone(`"Smith"`)'

match_rating_codex

Match Rating codex

Signature: string -> string

Examples:

# Common name
match_rating_codex('Smith') -> \"SMTH\"
# Another name
match_rating_codex('Johnson') -> \"JHNSN\"

CLI Usage:

echo '{}' | jpx 'match_rating_codex(`"Smith"`)'

metaphone

Metaphone phonetic code

Signature: string -> string

Examples:

# Common name
metaphone('Smith') -> \"SM0\"
# Ph sound
metaphone('phone') -> \"FN\"

CLI Usage:

echo '{}' | jpx 'metaphone(`"Smith"`)'

nysiis

NYSIIS phonetic code

Signature: string -> string

Examples:

# Common name
nysiis('Smith') -> \"SNAT\"
# Another name
nysiis('Johnson') -> \"JANSAN\"

CLI Usage:

echo '{}' | jpx 'nysiis(`"Smith"`)'

phonetic_match

Check phonetic match with algorithm

Signature: string, string, string -> boolean

Examples:

# Soundex match
phonetic_match('Smith', 'Smyth', 'soundex') -> true
# Metaphone match
phonetic_match('Robert', 'Rupert', 'metaphone') -> true
# No match
phonetic_match('John', 'Jane', 'soundex') -> false

CLI Usage:

echo '{}' | jpx 'phonetic_match(`"Smith"`, `"Smyth"`, `"soundex"`)'

soundex

Soundex phonetic code

Signature: string -> string

Examples:

# Common name
soundex('Robert') -> \"R163\"
# Same code as Robert
soundex('Rupert') -> \"R163\"
# Another name
soundex('Smith') -> \"S530\"

CLI Usage:

echo '{}' | jpx 'soundex(`"Robert"`)'

sounds_like

Check if strings sound similar

Signature: string, string -> boolean

Examples:

# Similar sounding
sounds_like('Robert', 'Rupert') -> true
# Spelling variants
sounds_like('Smith', 'Smyth') -> true
# Different names
sounds_like('John', 'Mary') -> false

CLI Usage:

echo '{}' | jpx 'sounds_like(`"Robert"`, `"Rupert"`)'