pinyin_to_hanzi
v0.1.0
Published
A package to convert pinyin to hanzi (Chinese character) eg: "nihao" -> "你好"
Downloads
1
Maintainers
Readme
What is it?
A package to convert pinyin to hanzi (Chinese character) eg: "nihao" -> "你好"
How it works
- Using a large Chinese corpus scan the most frequently occuring words
- Order the words based on frequency
- When the user types in pinyin find the most common characters
- If no matching values return the top partial matching values
- Uses WASM for speed
How to use it
import init, { pinyin_to_hanzi } from "./pinyin_to_hanzi.js";
async function initializeWASM() {
await init(); // Initialize the WASM module
}
async function runTest(pinyinInput) {
const result = pinyin_to_hanzi(pinyinInput);
// Result is a list of strings
}
initializeWASM(); // Initialize WASM as soon as the script loads