An incredibly advanced, local, and offline TypeScript universal romanizer for Japanese, Korean, and Hindi.
Built from scratch to handle some of the hardest linguistic complexities without relying on massive neural networks or cloud APIs.
- Contextual Tokenization: Uses
kuromoji(a lightweight 17MB dictionary-based morphological analyzer) to parse compound kanji accurately (e.g.過去形->kakokei, notka-kyo-kei). - Particle Tracking: Accurately maps grammatical particles based on sentence context (e.g.,
はaswa,へase,をaso). - Native Spacing Semantics: Automatically generates human-readable Romaji spacing akin to lyric websites (like Genius.com) by utilizing intelligent Part-of-Speech (POS) heuristics. Auxiliaries attach to verbs, tokens resolve suffixes, and particles stand independently.
- Sokuon (っ) Handling: Delays processing of double consonants until the tokenization string is fully formed to prevent mid-word gemination breaking.
- Zero Dependency: Maps all 11,172 possible Korean characters purely mathematically.
- Accurate Unicode Translation: Breaks down characters computationally by intersecting their Choseong, Jungseong, and Jongseong without arrays of static maps. Full batchim (bottom consonant) support!
- Schwa Deletion: Includes an advanced heuristic algorithm to naturally drop the trailing inherent 'a' sound (Schwa) where native speakers omit it (e.g.,
नमस्ते->namaste,पसंद->pasand). - Virama & Matra Mapping: Fully supports halants (viramas) perfectly cancelling inherent vowels.
npm install serikaromanizerimport { romanize } from "serikaromanizer";
async function run() {
// 🇯🇵 Japanese
const jaT = "困っちまうこれは誰かのせい。気付いたら大人になっていた。";
console.log(await romanize(jaT, "ja"));
// Output: komacchimau kore wa dareka no sei. kizuitara otona ni natteita.
// 🇰🇷 Korean
const koT = "안녕하세요! 흙길을 밟고 지나갔다.";
console.log(await romanize(koT, "ko"));
// Output: annyeonghaseyo! heulggileul balbgo jinagassda.
// 🇮🇳 Hindi
const hiT = "नमस्ते, आप कैसे हैं? मुझे हिंदी सीखना बहुत पसंद है।";
console.log(await romanize(hiT, "hi"));
// Output: namaste, aap kaise hain? mujhe hindii siikhnaa bahut pasand hai।
}
run();ja: Japaneseko: Koreanhi: Hindi
Pull requests are welcome! If you are fixing a bug, please include tests demonstrating the previous error.
MIT