cmpstr
Version:
CmpStr is a lightweight, fast and well performing package for calculating string similarity
50 lines (49 loc) • 1.93 kB
TypeScript
/**
* Soundex Phonetic Algorithm
* src/phonetic/Soudex.ts
*
* @see https://en.wikipedia.org/wiki/Soundex
*
* Soundex is a phonetic algorithm for indexing names by sound. It is used to
* encode words into a phonetic representation, allowing for the comparison of
* words based on their pronunciation rather than their spelling. This works
* by mapping letters to digits, ignoring certain letters, and applying specific
* rules to handle character combinations.
*
* It is particularly useful for matching names that may be spelled differently
* but sound similar and commonly used in genealogical research and databases
* to find similar-sounding names.
*
* The Soundex algorithm is not case-sensitive and ignores vowels and certain
* consonants. It outputs an array of strings that represents the phonetic code
* of the input, typically limited to the length of four characters.
*
* @module Phonetic/Soundex
* @author Paul Köhler (komed3)
* @license MIT
*/
import type { PhoneticOptions } from '../utils/Types';
import { Phonetic } from './Phonetic';
/**
* Soundex class extends the Phonetic class to implement the Soundex phonetic algorithm.
*/
export declare class Soundex extends Phonetic {
protected static default: PhoneticOptions;
/**
* Constructor for the Soundex class.
*
* Initializes the Soundex phonetic algorithm with the mapping and options.
*
* @param {PhoneticOptions} [opt] - Options for the Soundex phonetic algorithm
*/
constructor(opt?: PhoneticOptions);
/**
* Adjusts the phonetic code by removing leading zeros and ensuring the
* first character is uppercase.
*
* @param {string} code - The phonetic code to adjust
* @param {string[]} chars - The characters used in the phonetic code
* @returns {string} - The adjusted phonetic code
*/
protected adjustCode(code: string, chars: string[]): string;
}