简介
[PinYin.JS] 是一个纯JS实现的,简单,高效,快速的中文 <-> 拼音双向转换库,依赖于SeaJS的包管理
[PinYin.NodeJS] 在 [PinYin.JS] 的基础上进行了整合与修改,将原版的三个文件压缩合并为一个文件,并提供了标准的NodeJS接口,方便使用
下载
[下载地址]
说明
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// Dafault
var PinYinObject = PinYin("美的空调");
// Or Like This STYLE_NORMAL
/*var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_NORMAL,
heteronym: fasle
});*/
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'mei' ],
[ 'di' ],
[ 'kong' ],
[ 'tiao' ]
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// STYLE_TONE
var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_TONE,
heteronym: fasle
});
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'měi' ],
[ 'dí' ],
[ 'kōng' ],
[ 'tiáo' ]
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// STYLE_TONE2
var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_TONE2,
heteronym: fasle
});
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'mei3' ],
[ 'di2' ],
[ 'kong1' ],
[ 'tiao2' ]
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// STYLE_INITIALS
var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_INITIALS,
heteronym: fasle
});
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'm' ],
[ 'd' ],
[ 'k' ],
[ 't' ]
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// STYLE_FIRST_LETTER
var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_FIRST_LETTER,
heteronym: fasle
});
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'm' ],
[ 'd' ],
[ 'k' ],
[ 't' ]
// Load PinYin Module
var PinYin = require("../Module/PinYin");
// STYLE_NORMAL & heteronym == true
var PinYinObject = PinYin("美的空调", {
style: pinyin.STYLE_NORMAL,
heteronym: true
});
// Print it
console.log(Util.inspect(PinYinObject, false, 3, true));
// Console Out
[ 'mei' ],
[ 'di', 'de' ],
[ 'kong' ],
[ 'tiao', 'diao', 'zhou' ]
9 回复