pinyin_to_hanzi
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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

Package Sidebar

Install

npm i pinyin_to_hanzi

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

3.08 MB

Total Files

5

Last publish

Collaborators

  • jmikael_77