CmpStr - v3.2.1
    Preparing search index...

    Cologne class extends the Phonetic class to implement the Cologne phonetic algorithm.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Phonetic map and options for the algorithm

    optKey: string
    default: PhoneticOptions = ...

    Default options for the Cologne phonetic algorithm

    Methods

    • Adjusts the phonetic code by removing all '0's except the first character.

      Parameters

      • code: string

        The phonetic code to adjust

      Returns string

      • The adjusted phonetic code
    • Applies patterns to a word based on the phonetic map.

      This method processes the word by applying all defined patterns in the phonetic map. It replaces occurrences of specified patterns with their corresponding replacements.

      Parameters

      • word: string

        The input word to be processed

      Returns string

      • The modified word after applying all patterns
    • Applies phonetic rules to a character in a word context.

      This method is designed to be generic and efficient for all phonetic algorithms. It checks all rule types (prev, next, prevNot, nextNot, position, etc.) and returns either the appropriate code (string) or undefined.

      Parameters

      • char: string

        The current character

      • i: number

        The current position within the word

      • chars: string[]

        The word as an array of characters

      • charLen: number

        The total length of the word

      Returns string | undefined

      • The rule code or undefined if no rule applies
    • Generates the phonetic code for a given word.

      This method processes the word character by character, applying phonetic rules and mappings to generate a phonetic code.

      Parameters

      • word: string

        The input word to be converted into a phonetic code

      Returns string

      • The generated phonetic code
    • Ensures the phonetic code has a fixed length by padding or truncating.

      Parameters

      • input: string

        The input string to be adjusted

      Returns string

      • The adjusted string with fixed length
    • Determines whether to exit early based on the current phonetic code length.

      Parameters

      • code: string

        The current phonetic code

      • i: number

        The current index in the word

      Returns boolean

      • True if the code length exceeds the specified limit, false otherwise
    • Generates a phonetic index for the given input string.

      Parameters

      • input: string

        The input string to be indexed

      Returns string[]

      • An array of phonetic indices for the input words
    • Asynchronously generates a phonetic index for the given input string.

      Parameters

      • input: string

        The input string to be indexed

      Returns Promise<string[]>

      • A promise that resolves to an array of phonetic indices for the input words
    • Processes an array of words to generate their phonetic indices.

      This method iterates over each word, generates its phonetic code, and ensures that the resulting codes are of equal length.

      Parameters

      • words: string[]

        An array of words to be processed

      Returns string[]

      • An array of phonetic indices for the input words
    • Asynchronously processes an array of words to generate their phonetic indices.

      This method iterates over each word, generates its phonetic code asynchronously, and ensures that the resulting codes are of equal length.

      Parameters

      • words: string[]

        An array of words to be processed

      Returns Promise<string[]>

      • A promise that resolves to an array of phonetic indices for the input words
    • Converts a character to its phonetic code based on the mapping and rules.

      Parameters

      • char: string

        The current character

      • i: number

        The current position within the word

      • chars: string[]

        The word as an array of characters

      • charLen: number

        The total length of the word

      • lastCode: string | null

        The last code generated (to avoid duplicates)

      • map: Record<string, string>

        The phonetic mapping

      Returns string | undefined

      • The phonetic code or undefined if no code applies
    • Converts a word into an array of characters.

      Parameters

      • word: string

        The input word to be converted

      Returns string[]

      • An array of characters from the input word