项目作者: pepebecker

项目描述 :
Convert Hanzi to Pinyin and convert between Pinyin with tone marks and Pinyin with tone numbers.
高级语言: JavaScript
项目地址: git://github.com/pepebecker/pinyin-convert.git
创建时间: 2017-04-18T23:53:04Z
项目社区:https://github.com/pepebecker/pinyin-convert

开源协议:MIT License

下载


Pinyin Convert

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

Checkout the pinyin-webinterface which uses this module in the backend.

Install

  1. npm install pinyin-convert

Usage

  1. const convert = require('pinyin-convert')
  2. convert('Test: wǒ de māo xǐhuān hē niúnǎi')
  3. .then(console.log) // Te wo3 de mao1 xi3 huan1 he1 niu2 nai3
  4. convert('Test: wo3 de mao1 xi3huan1 he1 niu2nai3')
  5. .then(console.log) // Te wǒ de māo xǐ huān hē niú nǎi
  6. convert('Test: wǒ de māo xǐhuān hē niúnǎi', { everything: true })
  7. .then(console.log) // Test: wo3 de mao1 xi3huan1 he1 niu2nai3
  8. convert('Test: wo3 de mao1 xi3huan1 he1 niu2nai3', { everything: true })
  9. .then(console.log) // Test: wǒ de māo xǐhuān hē niúnǎi
  10. convert('我的猫喜欢喝牛奶')
  11. .then(console.log)
  12. // [ 'wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐ huan ', [ 'hē', 'hè' ], ' niú nǎi' ]
  13. convert('我的猫喜欢喝牛奶', { segmented: true })
  14. .then(console.log)
  15. // [ 'wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐhuan ', [ 'hē', 'hè' ], ' niúnǎi' ]
  16. convert('我的猫喜欢喝牛奶', { numbered: true, segmented: true })
  17. .then(console.log)
  18. // [ 'wo3 ', ['de5', 'di1', 'di2', 'di4'], ' mao1 xǐ5huan1 ', ['he1', 'he4'], ' niu2nai3' ]
  19. convert('Test: 我的猫喜欢喝牛奶', { everything: true, segmented: true })
  20. .then(console.log)
  21. // [ 'test: wǒ ', [ 'de', 'dī', 'dí', 'dì' ], ' māo xǐhuan ', [ 'hē', 'hè' ], ' niúnǎi' ]

Contributing

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