pepebecker / pinyin-api

API for the pinyin-rest server.
https://github.com/pepebecker/pinyin-api
MIT License
3 stars 1 forks source link
chinese hacktoberfest hanzi mandarin pinyin pinyin-api

Pinyin API

Travis Build Status Coverage Status Greenkeeper badge dependency status dev dependency status MIT-licensed chat on gitter

Install

npm install pepebecker/pinyin-api

Usage

const api = require('pinyin-api')

api.convert('我的猫喜欢喝牛奶')
.then(console.log)
// {
//   text: 'wǒ de māo xǐhuan hē niúnǎi',
//   data: [
//     'wǒ ',
//     [ 'de', 'dī', 'dí', 'dì' ],
//     ' māo xǐhuan ',
//     [ 'hē', 'hè' ],
//     ' niúnǎi'
//   ]
// }

api.convert('wo3 de mao1 xi3huan he1 niu2nai3')
.then(console.log)
// {
//   text: 'wǒ de māo xǐhuan hē niúnǎi',
//   data: 'wǒ de māo xǐhuan hē niúnǎi'
// }

api.convert('wǒ de māo xǐhuan hē niúnǎi')
.then(console.log)
// {
//   text: 'wo3 de5 mao1 xi3huan5 he1 niu2nai3',
//   data: 'wo3 de5 mao1 xi3huan5 he1 niu2nai3'
// }

api.split('wodemaoxihuanheniunai')
.then(console.log)
// {
//   text: 'wo de mao xi huan he niu nai',
//   data: [ 'wo', 'de', 'mao', 'xi', 'huan', 'he', 'niu', 'nai' ]
// }

Related

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.