/** * Utilities for preserving case patterns during translation. */ /** * Case pattern detected in a word. * - 'lower': all lowercase (hello) * - 'upper': all uppercase (HELLO) * - 'capitalized': first letter uppercase (Hello) * - 'mixed': mixed case like camelCase (GitHub, iPhone) */ type CasePattern = 'capitalized' | 'lower' | 'mixed' | 'upper'; /** * Applies a case pattern to a word, optionally using original word for mixed case. * Optimized: lowercase case returns word directly if already lowercase. */ declare function applyCasePattern(word: string, pattern: CasePattern, original?: string): string; /** * Detects the case pattern of a word. * Optimized for the common case (lowercase) by checking it first. */ declare function detectCasePattern(word: string): CasePattern; /** * Splits a word at camelCase boundaries. * e.g., "iCloud" -> ["i", "Cloud"], "MacBook" -> ["Mac", "Book"] */ declare function splitCamelCase(word: string): null | string[]; /** * Extracts URLs and emails from text, replacing them with placeholders. * Returns the modified text and a map to restore originals. * Placeholders use non-alphanumeric characters to avoid being split by word regex. */ declare function extractPreservedPatterns(text: string): { preserved: Map; text: string; }; /** * Normalizes various apostrophe characters to the standard straight apostrophe. * Handles: ' (U+2019 right single quotation mark), ' (U+2018 left), ʼ (U+02BC modifier letter) */ declare function normalizeApostrophes(text: string): string; /** * Strips diacritics/accents from text, preserving base letters. * Converts résumé→resume, naïve→naive, cliché→cliche, café→cafe. * Uses Unicode NFD decomposition to separate base letters from combining marks. */ declare function stripDiacritics(text: string): string; /** * Tokenization utilities for splitting text into word and non-word tokens. */ /** Regex to split text into word and non-word tokens (includes accented Latin chars). * Digit lookaround prevents matching letters in escape sequences like \u2014. */ declare const WORD_SPLIT_REGEX: RegExp; /** Regex to test if a token is a word (includes accented Latin chars) */ declare const WORD_TEST_REGEX: RegExp; /** * Token with text content and word/non-word classification. */ interface TextToken { isWord: boolean; text: string; } /** * Tokenizes IPA text into words and non-words (punctuation/whitespace). */ declare function tokenizeIPA(text: string): TextToken[]; /** * Tokenizes Ingglish/English text into words and non-words. * Words are sequences of letters and apostrophes. */ declare function tokenizeText(text: string): TextToken[]; export { type CasePattern, WORD_SPLIT_REGEX, WORD_TEST_REGEX, applyCasePattern, detectCasePattern, extractPreservedPatterns, normalizeApostrophes, splitCamelCase, stripDiacritics, tokenizeIPA, tokenizeText };