glot-chinese-utils
v0.0.9
Published
Utilities to transform Glot Chinese
Downloads
7
Readme
Usage
const utils = require('glot-chinese-utils')
console.log(utils.getToneNumber('shì')) // 4
console.log(utils.getToneNumber('shi4')) // 4
console.log(utils.removeTone('wǒ')) // wo
console.log(utils.removeTone('wo3')) // wo
console.log(utils.markToNumber('lǜ')) // lü4
console.log(utils.numberToMark('lü4')) // lǜ
// Detect if a string contains Simplified Chinese
utils.isSimplified('无需注册或设置')
// True
// Detect if a string contains Traditional Chinese
utils.isTraditional('無需帳戶或註冊。')
// True
// Detect if a string contains Traditional or Simplified Chinese characters
utils.detect('無需帳戶或註冊。')
// Detect if a string contains Simplified Chinese
utils.toSimplified('无需注册或设置')
// 斕需注內或論置
// Detect if a string contains Traditional Chinese
utils.toTraditional('斕需注內或論置。')
// 无需注册或设置'
utils.hasGrammars('無需帳戶或註冊。')
// 1 ~ undefinded
// utils.getHomos,
// utils.normalizePinyin
console.log(utils.split('本:wodemaoxihuanheniunai!'))
// ['wo', 'de', 'mao', 'xi', 'huan', 'he', 'niu', 'nai']
console.log(utils.split('本:wo de mao xihuan he niunai!'))
// ['wo', 'de', 'mao', 'xi', 'huan', 'he', 'niu', 'nai']
// return everything and wrap pinyin into lists
console.log(utils.split('本:ni jiao shenme mingzi?', true, true))
// ['本:'['ni'], ' ', ['jiao'], ' ', ['shen'], ['me'], ' ', ['ming'], ['zi'], '?']
// return everything and don't wrap pinyin into lists
console.log(utils.split('Nǐ huì shuō Yīngwén ma?', true))
// ['Nǐ', ' ', 'huì', ' ', 'shuō', ' ', 'Yīng', 'wén', ' ', 'ma', '?']