CmpStr - v3.2.1
    Preparing search index...
    Index

    Constructors

    Properties

    charFrequency: Map<string, number> = ...

    Frequency maps for characters and words

    sentences: string[] = []
    syllableCache: Map<string, number> = ...
    syllableStats?: {
        avg: number;
        median: number;
        mono: number;
        perWord: number[];
        total: number;
    }

    Cached syllable stats

    text: string

    The original text to analyze

    wordHistogram: Map<string, number> = ...
    words: string[] = []

    Tokenized words and sentences

    REGEX: {
        letter: RegExp;
        nonWord: RegExp;
        number: RegExp;
        sentence: RegExp;
        ucLetter: RegExp;
        vowelGroup: RegExp;
        word: RegExp;
    } = ...

    Regular expressions used in text analysis

    Methods

    • Computes character and word frequencies from the tokenized text.

      Returns void

    • Compute internal syllable stats.

      Returns { avg: number; median: number; mono: number; perWord: number[]; total: number }

      • Computed syllable stats
    • Estimates the number of syllables in a word using a simple heuristic. Uses caching to avoid redundant calculations for identical words.

      Parameters

      • word: string

        The word to estimate syllables for

      Returns number

      • Estimated syllable count
    • Gets the average sentence length in words.

      Returns number

      • Average length of sentences
    • Gets the average number of syllables per word in the text.

      Returns number

      • Average syllables per word
    • Gets the average word length in the text.

      Returns number

      • Average length of words
    • Gets the frequency of each character in the text.

      Returns Record<string, number>

      • A record of character frequencies
    • Gets the least common words (hapax legomena) in the text. Hapax legomena are words that occur only once in the text.

      Returns string[]

      • Array of hapax legomena
    • Calculates the Honore's R statistic for the text as a measure of lexical richness.

      Returns number

      • The Honore's R statistic
    • Gets the original text length in characters.

      Returns number

      • Length of the text
    • Calculates the LIX (Lesbarhetsindex) score for the text. The LIX score is a readability index that combines average word length and sentence length.

      Returns number

      • The LIX score
    • Gets the ratio of long words (words with length >= len) to total words.

      Parameters

      • Optionallen: number = 7

        Minimum length for a word to be considered long

      Returns number

      • Ratio of long words to total words
    • Gets the number of words with at most a specified maximum syllable count.

      Parameters

      • max: number

        Maximum syllable count for a word to be included

      Returns number

      • Count of words meeting the syllable criteria
    • Gets the median number of syllables per word in the text.

      Returns number

      • Median syllables per word
    • Gets the number of words with at least a specified minimum syllable count.

      Parameters

      • min: number

        Minimum syllable count for a word to be included

      Returns number

      • Count of words meeting the syllable criteria
    • Gets the number of monosyllabic words (words with exactly one syllable).

      Returns number

      • Count of monosyllabic words
    • Gets the most common words in the text, limited to a specified number.

      Parameters

      • Optionallimit: number = 5

        Maximum number of common words to return

      Returns string[]

      • Array of the most common words
    • Calculates various readability scores based on the text.

      This method supports multiple readability metrics:

      • Flesch Reading Ease
      • Flesch-Kincaid Grade Level

      Parameters

      • Optionalmetric: "flesch" | "fleschde" | "kincaid" = 'flesch'

        The readability metric to calculate

      Returns number

      • The calculated readability score
    • Estimates the reading time for the text based on words per minute (WPM).

      Parameters

      • Optionalwpm: number = 200

        Words per minute for the calculation

      Returns number

      • Estimated reading time in minutes
    • Gets the number of sentences in the text.

      Returns number

      • Count of sentences
    • Gets the ratio of short words (words with length <= len) to total words.

      Parameters

      • Optionallen: number = 3

        Maximum length for a word to be considered short

      Returns number

      • Ratio of short words to total words
    • Estimates the number of syllables in the text.

      Returns number

      • Total estimated syllable count
    • Gets the frequency of Unicode codepoints in the text.

      Returns Record<string, number>

      • A record of Unicode codepoint frequencies
    • Calculates the ratio of uppercase letters to total letters in the text.

      Returns number

      • Ratio of uppercase letters to total letters
    • Gets the number of words in the text.

      Returns number

      • Count of words
    • Gets a histogram of word frequencies in the text.

      Returns Record<string, number>

      • A histogram of word frequencies
    • Calculates the Wiener Sachtextformel (WSTF) scores for the text. The WSTF scores are a set of readability metrics based on word and sentence characteristics.

      Returns [number, number, number, number]

      • An array of WSTF scores
    • Checks if the text contains any numbers.

      Returns boolean

      • True if numbers are present, false otherwise