0.1.0 • Published 8 months ago

pinyin_to_hanzi v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

What is it?

A package to convert pinyin to hanzi (Chinese character) eg: "nihao" -> "你好"

How it works

  1. Using a large Chinese corpus scan the most frequently occuring words
  2. Order the words based on frequency
  3. When the user types in pinyin find the most common characters
  4. If no matching values return the top partial matching values
  5. 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