UNPKG

urdu-text-utils

Version:

Comprehensive Urdu NLP & text processing toolkit: normalization, Roman Urdu transliteration, stop words, script detection, digits, diacritics (aerab), sorting, search, and statistics. Zero dependencies, ESM + CJS.

50 lines (49 loc) • 2.06 kB
/** Common Urdu first names mapped to their standard English spellings. */ export declare const URDU_FIRST_NAMES: Record<string, string>; /** Common Urdu family/last names mapped to their standard English spellings. */ export declare const URDU_FAMILY_NAMES: Record<string, string>; /** Honorific titles used in Urdu names. */ export declare const HONORIFICS: Record<string, string>; /** Name prefixes that are kept in both languages. */ export declare const NAME_PREFIXES: Record<string, string>; /** * Alternate English spellings of names already in the forward tables * (e.g. `Omar` for عمر, canonically spelled `Umar` in English). * Exported so the PHP port can consume the identical list via tables.json. */ export declare const ENGLISH_NAME_ALIASES: Record<string, string>; export interface NameTransliterationOptions { /** Preserve the original case of the English name. Default: true (capitalized). */ preserveCase?: boolean; /** Include honorifics in the output. Default: true. */ includeHonorifics?: boolean; } /** * Transliterate an Urdu name to English. * * @example * transliterateNameToEnglish("محمد علی") // "Muhammad Ali" * transliterateNameToEnglish("جناب خان صاحب") // "Janab Khan Sahib" */ export declare function transliterateNameToEnglish(urduName: string, options?: NameTransliterationOptions): string; /** * Transliterate an English name to Urdu script. * * @example * transliterateNameToUrdu("Muhammad Ali") // "محمد علی" * transliterateNameToUrdu("Janab Khan Sahib") // "جناب خان صاحب" */ export declare function transliterateNameToUrdu(englishName: string): string; /** * Extract name parts from a full Urdu name. * * @example * extractNameParts("جناب محمد علی خان صاحب") * // { honorific: "جناب", firstName: "محمد علی", familyName: "خان", suffix: "صاحب" } */ export declare function extractNameParts(fullName: string): { honorific?: string; firstName: string; familyName?: string; suffix?: string; };