/** * Removes Indonesian affixes (prefixes and suffixes) from a word. * * Strips common Indonesian morphological affixes such as: * - Prefixes: me-, di-, ber-, pe-, pe-, ku-, kau-, men-, men-, per-, dll * - Suffixes: -kan, -an, -nya, -lah, -tah, -pun * * Used for text normalization, search indexing, and linguistic analysis. * * @param text - Word or text to strip affixes from * @returns Text with affixes removed * * @example * ```typescript * stemText('mempertanggungjawabkan'); // 'tanggung jawab' * stemText('berbicara'); // 'bicara' * stemText('mahasiswanya'); // 'mahasisw' * ``` * * @example * For search optimization: * ```typescript * const query = 'mempertanggungjawabkan'; * const normalized = stemText(query); // 'tanggung jawab' * // Use normalized for Indonesian full-text search * ``` */ declare function stemText(text: string): string; /** * Encodes a name into a phonetic code for fuzzy matching. * * Uses Soundex-like algorithm adapted for Indonesian names. * Handles Dutch and Arabic name normalizations for better * matching accuracy in Indonesian context. * * @param text - Name to encode (e.g., person name) * @returns Phonetic code (1 letter + 3 digits, e.g., 'S635') * * @example * ```typescript * encodePhonetic('Syahruddin'); // 'S635' * encodePhonetic('Ahmad'); // 'A530' * ``` * * @example * For fuzzy name matching: * ```typescript * const code1 = encodePhonetic('Budi'); * const code2 = encodePhonetic('Budi'); // same code = match * // Useful for deduping names with spelling variations * ``` */ declare function encodePhonetic(text: string): string; /** * Checks if two names match phonetically. * * Compares the phonetic codes of two names to determine * if they likely refer to the same person despite spelling * variations (typos, nicknames, alternative spellings). * * @param text1 - First name to compare * @param text2 - Second name to compare * @returns `true` if names match phonetically, `false` otherwise * * @example * ```typescript * isPhoneticMatch('Syahruddin', 'Syahrudin'); // true * isPhoneticMatch('Budi', 'Budi'); // true * isPhoneticMatch('Andi', 'Budi'); // false * ``` * * @example * For search-as-you-type: * ```typescript * const typed = 'Syahrudin'; * const candidates = ['Syahruddin', 'Budi', 'Andi']; * const match = candidates.find(c => isPhoneticMatch(typed, c)); * // Returns 'Syahruddin' * ``` */ declare function isPhoneticMatch(text1: string, text2: string): boolean; /** * Splits Indonesian text into sentences. * * Handles Indonesian abbreviations (Yth., Bpk., Sdr., dll) * so periods inside abbreviations don't create false sentence breaks. * * @param text - Text to tokenize into sentences * @returns Array of sentences (empty array if input is empty/invalid) * * @example * ```typescript * tokenizeIndo("Kpd Yth. Bpk. Budi."); // ["Kpd Yth. Bpk. Budi."] * tokenizeIndo("Halo. Selamat pagi."); // ["Halo.", "Selamat pagi."] * ``` * * @example * For processing formal Indonesian letters: * ```typescript * const letter = "Hormat kami, PT ABC.Jl. Merdeka No.10"; * const sentences = tokenizeIndo(letter); * // Properly handles "Jl." (Jalan) abbreviation * ``` */ declare function tokenizeIndo(text: string): string[]; /** * Collapses multiple spaces to single space and trims. * * @param text - Text to normalize * @returns Text with normalized whitespace * * @example * ```typescript * normalizeWhitespace(" Budi pergi ke sekolah ") * // "Budi pergi ke sekolah" * ``` */ declare function normalizeWhitespace(text: string): string; /** * Removes all non-letter/number characters except spaces. * * @param text - Text to clean * @returns Text with only letters, numbers, and spaces * * @example * ```typescript * stripNonAlphanumeric("Budi123@#$%"); // "Budi123" * stripNonAlphanumeric("Hello! World?"); // "Hello World" * ``` */ declare function stripNonAlphanumeric(text: string): string; /** * NLP Engine types for Indonesian text processing. * * @module nlp */ /** * Phonetic encoding result with metadata. */ interface PhoneticResult { /** Original text */ original: string; /** Encoded phonetic representation */ code: string; } /** * Tokenization result with sentence boundaries. */ interface TokenizationResult { /** Array of sentences */ sentences: string[]; /** Positions of sentence boundaries */ positions: number[]; } /** * Stemming result with removed affixes. */ interface StemmingResult { /** Original word */ original: string; /** Stemmed word */ stem: string; /** Removed affixes */ removedAffixes: string[]; } /** * ============================================================================ * INDONESIAN NLP ENGINE - CONSTANTS * ============================================================================ * * This file contains constants for Indonesian text processing: * - AFFIX_PATTERNS: Indonesian prefix and suffix patterns for stemming * - ABBREVIATIONS: Common Indonesian abbreviations to preserve in tokenization * - PHONETIC_MAP: Character mappings for phonetic encoding * * ============================================================================ */ /** * Common Indonesian abbreviations that should NOT be split on periods * during sentence tokenization. */ declare const SENTENCE_ABBREVIATIONS: readonly ["Yth.", "Bpk.", "Ibu.", "Sdr.", "S.Kom.", "M.Kom.", "Dr.", "Sp.", "Mk.", "Jl.", "D.a.", "D.l."]; /** * Indonesian prefix patterns for algorithmic stemming. * Order matters - longer patterns should be checked first. */ declare const PREFIX_PATTERNS: readonly [{ readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: "s"; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: "s"; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }]; /** * Indonesian suffix patterns for algorithmic stemming. * Order matters - longer patterns should be checked first. */ declare const SUFFIX_PATTERNS: readonly [{ readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }, { readonly pattern: RegExp; readonly replacement: ""; }]; export { PREFIX_PATTERNS, type PhoneticResult, SENTENCE_ABBREVIATIONS, SUFFIX_PATTERNS, type StemmingResult, type TokenizationResult, encodePhonetic, isPhoneticMatch, normalizeWhitespace, stemText, stripNonAlphanumeric, tokenizeIndo };