Files
ingglish-hyperdope-gematria/node_modules/@ingglish/dictionary/dist/index.d.cts
T

99 lines
3.5 KiB
TypeScript

/**
* Custom pronunciations that override CMU dictionary entries or add missing words.
*
* Two categories:
* 1. CMU corrections — fix errors in existing CMU entries (verified vs Cambridge/Wiktionary)
* 2. Additions — words not in CMU (tech terms, loanwords, etc.)
*
* Note: ~800 N-before-velar errors (N K → NG K, N G → NG G) are fixed automatically
* by normalizeVelarNasal() in lookup.ts and don't need entries here.
*/
declare const CUSTOM_PRONUNCIATIONS: Record<string, string[]>;
/**
* Gets custom pronunciation for a word.
* @param word The word to look up (should be lowercase for best performance)
*/
declare function getCustomPronunciation(word: string): string[] | undefined;
/**
* Checks if a word has a custom pronunciation.
* @param word The word to look up (should be lowercase for best performance)
*/
declare function hasCustomPronunciation(word: string): boolean;
/**
* Word frequency scoring using SUBTLEX corpus data.
* Used for selecting the most common word among homophones.
*/
/**
* Returns the frequency count for a word (higher = more common).
* Returns undefined if word is not in the corpus or data hasn't loaded yet.
*/
declare function getWordFrequency(word: string): number | undefined;
/**
* Loads word frequency data.
* The data is cached after first load.
*/
declare function loadFrequencies(): Promise<Record<string, number>>;
/**
* Sorts words by frequency (most common first).
*/
declare function sortByFrequency(words: string[]): string[];
type CMUDictionary = Record<string, string[]>;
type ReverseDictionary = Record<string, string[]>;
/**
* CMU Dictionary loading and caching.
*
* Dictionary sourced from: https://github.com/cmusphinx/cmudict
*/
/**
* Loads the CMU Pronouncing Dictionary.
* The dictionary is cached after first load.
*/
declare const loadDictionary: () => Promise<CMUDictionary>;
/**
* Gets the dictionary synchronously.
* Throws if dictionary hasn't been loaded yet.
*/
declare const getDictionary: () => CMUDictionary;
/**
* Checks if the dictionary is loaded.
*/
declare const isDictionaryLoaded: () => boolean;
/**
* Looks up a word in the CMU dictionary, returning the ARPAbet IR.
* Custom pronunciations override dictionary entries.
* @param word The word to look up (case insensitive)
* @returns ARPAbet phoneme array (the pipeline IR), or null if not found
*/
declare function lookupPronunciation(word: string): null | string[];
/**
* Like {@link lookupPronunciation}, but takes a **pre-lowercased** key.
* Skips the `.toLowerCase()` call — use when the caller has already
* confirmed the key is lowercase (e.g., fast-path code).
*/
declare function lookupPronunciationLower(key: string): null | string[];
/**
* Reverse dictionary: phoneme sequence -> English words.
*
* Used for reverse translation (Ingglish/IPA -> English).
* Pre-built at build time with words sorted by frequency.
*/
/**
* Loads the pre-built reverse dictionary.
* The dictionary is cached after first load.
*/
declare const loadReverseDictionary: () => Promise<ReverseDictionary>;
/**
* Looks up words for a phoneme key.
* Results are pre-merged and frequency-sorted at load time.
*/
declare function lookupPhonemeKey(key: string): string[] | undefined;
export { CUSTOM_PRONUNCIATIONS, getCustomPronunciation, getDictionary, getWordFrequency, hasCustomPronunciation, isDictionaryLoaded, loadDictionary, loadFrequencies, loadReverseDictionary, lookupPhonemeKey, lookupPronunciation, lookupPronunciationLower, sortByFrequency };