UNPKG

@unglish/word-generator

Version:

A simple generator for creating unglish words.

28 lines 1.7 kB
import { Phoneme, WordGenerationOptions, Word } from "../types.js"; /** * Builds a phoneme cluster for either the onset or coda of a syllable. * * @param type - The type of cluster to build: "onset" or "coda". * @param maxLength - The maximum number of phonemes allowed in the cluster. Default is 3. * @param ignore - An array of phoneme sounds to ignore when building the cluster. Default is an empty array. * @returns An array of Phoneme objects representing the built cluster. * * This function constructs a phoneme cluster following English phonotactic rules: * 1. It respects sonority sequencing (increasing for onset, decreasing for coda). * 2. It avoids invalid clusters as defined in invalidOnsetClusters and invalidCodaClusters. * 3. It handles special cases, such as 's' clusters in onsets and limitations on liquids and nasals. * 4. It considers phoneme-specific constraints like start/end of word positions. * * The function stops building the cluster when it reaches maxLength, runs out of valid candidates, * or encounters specific conditions (e.g., two-phoneme onset ending in a liquid or nasal). */ export declare function buildCluster(position: "onset" | "coda" | "nucleus", maxLength: number | undefined, ignore: string[] | undefined, isStartOfWord: Boolean, isEndOfWord: Boolean): Phoneme[]; /** * Generates a word with a specified number of syllables. * * @param options - An object containing options for the word generation. * @returns A Word object containing the syllables, pronunciation, and written form. */ export declare const generateWord: (options?: WordGenerationOptions) => Word; export default generateWord; //# sourceMappingURL=generate.d.ts.map