This repo only implements the pinyin engine and does not have a virtual keyboard
- download
rawdict_utf16_65105_freq.txtfrom PinyinIME archive - extra
PinyinIME-refs_heads_main/jni/data/rawdict_utf16_65105_freq.txtto scripts folder - convert encode to
UTF-8
iconv -f UTF-16 -t UTF-8 rawdict_utf16_65105_freq.txt > google_pinyin_rawdict_utf8_65105_freq.txt- build dict
node scripts/preprocess.mjsconst dict = {
b: [
{ w: '菝', f: 2.53953332627 }, // ba
{ w: '柏', f: 794.770968525 }, // bai
],
ba: [
{ w: '菝', f: 2.53953332627 },
{ w: '办案', f: 824.018360007 }, // ban'an
],
}// dict structure ⬆️
const ime = new PinyinIME(dict)
ime.input('nou')
// read this field to get all hanzi candidates
console.log(ime.candidates)
// read this field to get current hanzi&pinyin combo
console.log(ime.label)
const ret = ime.pickCandidate(0)
// pickCandidate will return the result
interface Result {
cadence: boolean // true mean all pinyin has converted to hanzi
word: string // current picked word
token: string //current picked token
}