Phonetic Functions
Phonetic encoding functions for sound-based string matching.
Summary
| Function | Signature | Description |
|---|---|---|
caverphone | string -> string | Caverphone code |
caverphone2 | string -> string | Caverphone 2 code |
double_metaphone | string -> object | Double Metaphone codes |
match_rating_codex | string -> string | Match Rating codex |
metaphone | string -> string | Metaphone phonetic code |
nysiis | string -> string | NYSIIS phonetic code |
phonetic_match | string, string, string -> boolean | Check phonetic match with algorithm |
soundex | string -> string | Soundex phonetic code |
sounds_like | string, string -> boolean | Check 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"`)'