You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
77 KiB
JavaScript

11 months ago
/**
* @Description: 汉字转拼音
* @author: mihuc
* @version 1.0.0
* @LicenseMIT
*/
layui.define([], function (exports) {
var PinYinConfig = { "a": "\u554a\u963f\u9515", "ai": "\u57c3\u6328\u54ce\u5509\u54c0\u7691\u764c\u853c\u77ee\u827e\u788d\u7231\u9698\u8bf6\u6371\u55f3\u55cc\u5ad2\u7477\u66a7\u7839\u953f\u972d", "an": "\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u8c19\u57ef\u63de\u72b4\u5eb5\u6849\u94f5\u9e4c\u9878\u9eef", "ang": "\u80ae\u6602\u76ce", "ao": "\u51f9\u6556\u71ac\u7ff1\u8884\u50b2\u5965\u61ca\u6fb3\u5773\u62d7\u55f7\u5662\u5c99\u5ed2\u9068\u5aaa\u9a9c\u8071\u87af\u93ca\u9ccc\u93d6", "ba": "\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u575d\u9738\u7f62\u7238\u8307\u83dd\u8406\u636d\u5c9c\u705e\u6777\u94af\u7c91\u9c85\u9b43", "bai": "\u767d\u67cf\u767e\u6446\u4f70\u8d25\u62dc\u7a17\u859c\u63b0\u97b4", "ban": "\u6591\u73ed\u642c\u6273\u822c\u9881\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u529e\u7eca\u962a\u5742\u8c73\u94a3\u7622\u764d\u8228", "bang": "\u90a6\u5e2e\u6886\u699c\u8180\u7ed1\u68d2\u78c5\u868c\u9551\u508d\u8c24\u84a1\u8783", "bao": "\u82de\u80de\u5305\u8912\u96f9\u4fdd\u5821\u9971\u5b9d\u62b1\u62a5\u66b4\u8c79\u9c8d\u7206\u52f9\u8446\u5b80\u5b62\u7172\u9e28\u8913\u8db5\u9f85", "bo": "\u5265\u8584\u73bb\u83e0\u64ad\u62e8\u94b5\u6ce2\u535a\u52c3\u640f\u94c2\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u9a73\u4eb3\u8543\u5575\u997d\u6a97\u64d8\u7934\u94b9\u9e41\u7c38\u8ddb", "bei": "\u676f\u7891\u60b2\u5351\u5317\u8f88\u80cc\u8d1d\u94a1\u500d\u72c8\u5907\u60eb\u7119\u88ab\u5b5b\u9642\u90b6\u57e4\u84d3\u5457\u602b\u6096\u789a\u9e4e\u8919\u943e", "ben": "\u5954\u82ef\u672c\u7b28\u755a\u574c\u951b", "beng": "\u5d29\u7ef7\u752d\u6cf5\u8e66\u8ff8\u552a\u5623\u750f", "bi": "\u903c\u9f3b\u6bd4\u9119\u7b14\u5f7c\u78a7\u84d6\u853d\u6bd5\u6bd9\u6bd6\u5e01\u5e87\u75f9\u95ed\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u5315\u4ef3\u4ffe\u8298\u835c\u8378\u5421\u54d4\u72f4\u5eb3\u610e\u6ed7\u6fde\u5f3c\u59a3\u5a62\u5b16\u74a7\u8d32\u7540\u94cb\u79d5\u88e8\u7b5a\u7b85\u7be6\u822d\u895e\u8df8\u9ac0", "bian": "\u97ad\u8fb9\u7f16\u8d2c\u6241\u4fbf\u53d8\u535e\u8fa8\u8fa9\u8fab\u904d\u533e\u5f01\u82c4\u5fed\u6c74\u7f0f\u7178\u782d\u78a5\u7a39\u7a86\u8759\u7b3e\u9cca", "biao": "\u6807\u5f6a\u8198\u8868\u5a4a\u9aa0\u98d1\u98d9\u98da\u706c\u9556\u9573\u762d\u88f1\u9cd4", "bie": "\u9cd6\u618b\u522b\u762a\u8e69\u9cd8", "bin": "\u5f6c\u658c\u6fd2\u6ee8\u5bbe\u6448\u50a7\u6d5c\u7f24\u73a2\u6ba1\u8191\u9554\u9acc\u9b13", "bing": "\u5175\u51b0\u67c4\u4e19\u79c9\u997c\u70b3\u75c5\u5e76\u7980\u90b4\u6452\u7ee0\u678b\u69df\u71f9", "bu": "\u6355\u535c\u54fa\u8865\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u62ca\u535f\u900b\u74ff\u6661\u949a\u91ad", "ca": "\u64e6\u5693\u7924", "cai": "\u731c\u88c1\u6750\u624d\u8d22\u776c\u8e29\u91c7\u5f69\u83dc\u8521", "can": "\u9910\u53c2\u8695\u6b8b\u60ed\u60e8\u707f\u9a96\u74a8\u7cb2\u9eea", "cang": "\u82cd\u8231\u4ed3\u6ca7\u85cf\u4f27", "cao": "\u64cd\u7cd9\u69fd\u66f9\u8349\u8279\u5608\u6f15\u87ac\u825a", "ce": "\u5395\u7b56\u4fa7\u518c\u6d4b\u5202\u5e3b\u607b", "ceng": "\u5c42\u8e6d\u564c", "cha": "\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8be7\u7339\u9987\u6c4a\u59f9\u6748\u6942\u69ce\u6aab\u9497\u9538\u9572\u8869", "chai": "\u62c6\u67f4\u8c7a\u4faa\u8308\u7625\u867f\u9f87", "chan": "\u6400\u63ba\u8749\u998b\u8c17\u7f20\u94f2\u4ea7\u9610\u98a4\u5181\u8c04\u8c36\u8487\u5edb\u5fcf\u6f7a\u6fb6\u5b71\u7fbc\u5a75\u5b17\u9aa3\u89c7\u7985\u9561\u88e3\u87fe\u8e94", "chang": "\u660c\u7316\u573a\u5c1d\u5e38\u957f\u507f\u80a0\u5382\u655e\u7545\u5531\u5021\u4f25\u9b2f\u82cc\u83d6\u5f9c\u6005\u60dd\u960a\u5a3c\u5ae6\u6636\u6c05\u9cb3", "chao": "\u8d85\u6284\u949e\u671d\u5632\u6f6e\u5de2\u5435\u7092\u600a\u7ec9\u6641\u8016", "che": "\u8f66\u626f\u64a4\u63a3\u5f7b\u6f88\u577c\u5c6e\u7817", "chen": "\u90f4\u81e3\u8fb0\u5c18\u6668\u5ff1\u6c89\u9648\u8d81\u886c\u79f0\u8c0c\u62bb\u55d4\u5bb8\u741b\u6987\u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WZCSRKQYTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYWYWNQCCLDDNYYYNYCKCZHXX
//此处收录了375个多音字
var oMultiDiff = {
"19969": "DZ",
"19975": "WM",
"19988": "QJ",
"20048": "YL",
"20056": "SC",
"20060": "NM",
"20094": "QG",
"20127": "QJ",
"20167": "QC",
"20193": "YG",
"20250": "KH",
"20256": "ZC",
"20282": "SC",
"20285": "QJG",
"20291": "TD",
"20314": "YD",
"20340": "NE",
"20375": "TD",
"20389": "YJ",
"20391": "CZ",
"20415": "PB",
"20446": "YS",
"20447": "SQ",
"20504": "TC",
"20608": "KG",
"20854": "QJ",
"20857": "ZC",
"20911": "PF",
"20504": "TC",
"20608": "KG",
"20854": "QJ",
"20857": "ZC",
"20911": "PF",
"20985": "AW",
"21032": "PB",
"21048": "XQ",
"21049": "SC",
"21089": "YS",
"21119": "JC",
"21242": "SB",
"21273": "SC",
"21305": "YP",
"21306": "QO",
"21330": "ZC",
"21333": "SDC",
"21345": "QK",
"21378": "CA",
"21397": "SC",
"21414": "XS",
"21442": "SC",
"21477": "JG",
"21480": "TD",
"21484": "ZS",
"21494": "YX",
"21505": "YX",
"21512": "HG",
"21523": "XH",
"21537": "PB",
"21542": "PF",
"21549": "KH",
"21571": "E",
"21574": "DA",
"21588": "TD",
"21589": "O",
"21618": "ZC",
"21621": "KHA",
"21632": "ZJ",
"21654": "KG",
"21679": "LKG",
"21683": "KH",
"21710": "A",
"21719": "YH",
"21734": "WOE",
"21769": "A",
"21780": "WN",
"21804": "XH",
"21834": "A",
"21899": "ZD",
"21903": "RN",
"21908": "WO",
"21939": "ZC",
"21956": "SA",
"21964": "YA",
"21970": "TD",
"22003": "A",
"22031": "JG",
"22040": "XS",
"22060": "ZC",
"22066": "ZC",
"22079": "MH",
"22129": "XJ",
"22179": "XA",
"22237": "NJ",
"22244": "TD",
"22280": "JQ",
"22300": "YH",
"22313": "XW",
"22331": "YQ",
"22343": "YJ",
"22351": "PH",
"22395": "DC",
"22412": "TD",
"22484": "PB",
"22500": "PB",
"22534": "ZD",
"22549": "DH",
"22561": "PB",
"22612": "TD",
"22771": "KQ",
"22831": "HB",
"22841": "JG",
"22855": "QJ",
"22865": "XQ",
"23013": "ML",
"23081": "WM",
"23487": "SX",
"23558": "QJ",
"23561": "YW",
"23586": "YW",
"23614": "YW",
"23615": "SN",
"23631": "PB",
"23646": "ZS",
"23663": "ZT",
"23673": "YG",
"23762": "TD",
"23769": "ZS",
"23780": "QJ",
"23884": "QK",
"24055": "XH",
"24113": "DC",
"24162": "ZC",
"24191": "GA",
"24273": "QJ",
"24324": "NL",
"24377": "TD",
"24378": "QJ",
"24439": "PF",
"24554": "ZS",
"24683": "TD",
"24694": "WE",
"24733": "LK",
"24925": "TN",
"25094": "ZG",
"25100": "XQ",
"25103": "XH",
"25153": "PB",
"25170": "PB",
"25179": "KG",
"25203": "PB",
"25240": "ZS",
"25282": "FB",
"25303": "NA",
"25324": "KG",
"25341": "ZY",
"25373": "WZ",
"25375": "XJ",
"25384": "A",
"25457": "A",
"25528": "SD",
"25530": "SC",
"25552": "TD",
"25774": "ZC",
"25874": "ZC",
"26044": "YW",
"26080": "WM",
"26292": "PB",
"26333": "PB",
"26355": "ZY",
"26366": "CZ",
"26397": "ZC",
"26399": "QJ",
"26415": "ZS",
"26451": "SB",
"26526": "ZC",
"26552": "JG",
"26561": "TD",
"26588": "JG",
"26597": "CZ",
"26629": "ZS",
"26638": "YL",
"26646": "XQ",
"26653": "KG",
"26657": "XJ",
"26727": "HG",
"26894": "ZC",
"26937": "ZS",
"26946": "ZC",
"26999": "KJ",
"27099": "KJ",
"27449": "YQ",
"27481": "XS",
"27542": "ZS",
"27663": "ZS",
"27748": "TS",
"27784": "SC",
"27788": "ZD",
"27795": "TD",
"27812": "O",
"27850": "PB",
"27852": "MB",
"27895": "SL",
"27898": "PL",
"27973": "QJ",
"27981": "KH",
"27986": "HX",
"27994": "XJ",
"28044": "YC",
"28065": "WG",
"28177": "SM",
"28267": "QJ",
"28291": "KH",
"28337": "ZQ",
"28463": "TL",
"28548": "DC",
"28601": "TD",
"28689": "PB",
"28805": "JG",
"28820": "QG",
"28846": "PB",
"28952": "TD",
"28975": "ZC",
"29100": "A",
"29325": "QJ",
"29575": "SL",
"29602": "FB",
"30010": "TD",
"30044": "CX",
"30058": "PF",
"30091": "YSP",
"30111": "YN",
"30229": "XJ",
"30427": "SC",
"30465": "SX",
"30631": "YQ",
"30655": "QJ",
"30684": "QJG",
"30707": "SD",
"30729": "XH",
"30796": "LG",
"30917": "PB",
"31074": "NM",
"31085": "JZ",
"31109": "SC",
"31181": "ZC",
"31192": "MLB",
"31293": "JQ",
"31400": "YX",
"31584": "YJ",
"31896": "ZN",
"31909": "ZY",
"31995": "XJ",
"32321": "PF",
"32327": "ZY",
"32418": "HG",
"32420": "XQ",
"32421": "HG",
"32438": "LG",
"32473": "GJ",
"32488": "TD",
"32521": "QJ",
"32527": "PB",
"32562": "ZSQ",
"32564": "JZ",
"32735": "ZD",
"32793": "PB",
"33071": "PF",
"33098": "XL",
"33100": "YA",
"33152": "PB",
"33261": "CX",
"33324": "BP",
"33333": "TD",
"33406": "YA",
"33426": "WM",
"33432": "PB",
"33445": "JG",
"33486": "ZN",
"33493": "TS",
"33507": "QJ",
"33540": "QJ",
"33544": "ZC",
"33564": "XQ",
"33617": "YT",
"33632": "QJ",
"33636": "XH",
"33637": "YX",
"33694": "WG",
"33705": "PF",
"33728": "YW",
"33882": "SR",
"34067": "WM",
"34074": "YW",
"34121": "QJ",
"34255": "ZC",
"34259": "XL",
"34425": "JH",
"34430": "XH",
"34485": "KH",
"34503": "YS",
"34532": "HG",
"34552": "XS",
"34558": "YE",
"34593": "ZL",
"34660": "YQ",
"34892": "XH",
"34928": "SC",
"34999": "QJ",
"35048": "PB",
"35059": "SC",
"35098": "ZC",
"35203": "TQ",
"35265": "JX",
"35299": "JX",
"35782": "SZ",
"35828": "YS",
"35830": "E",
"35843": "TD",
"35895": "YG",
"35977": "MH",
"36158": "JG",
"36228": "QJ",
"36426": "XQ",
"36466": "DC",
"36710": "JC",
"36711": "ZYG",
"36767": "PB",
"36866": "SK",
"36951": "YW",
"37034": "YX",
"37063": "XH",
"37218": "ZC",
"37325": "ZC",
"38063": "PB",
"38079": "TD",
"38085": "QY",
"38107": "DC",
"38116": "TD",
"38123": "YD",
"38224": "HG",
"38241": "XTC",
"38271": "ZC",
"38415": "YE",
"38426": "KH",
"38461": "YD",
"38463": "AE",
"38466": "PB",
"38477": "XJ",
"38518": "YT",
"38551": "WK",
"38585": "ZC",
"38704": "XS",
"38739": "LJ",
"38761": "GJ",
"38808": "SQ",
"39048": "JG",
"39049": "XJ",
"39052": "HG",
"39076": "CZ",
"39271": "XT",
"39534": "TD",
"39552": "TD",
"39584": "PB",
"39647": "SB",
"39730": "LG",
"39748": "TPB",
"40109": "ZQ",
"40479": "ND",
"40516": "HG",
"40536": "HG",
"40583": "QJ",
"40765": "YQ",
"40784": "QJ",
"40840": "YK",
"40863": "QJG"
};
PinYin = function () {
};
/**
* 汉字转拼音
* @param {any} 汉字
* @return 拼音
*/
PinYin.prototype.ConvertPinyin = function (l1) {
var l2 = l1.length;
var I1 = "";
var reg = new RegExp('[a-zA-Z0-9\- ]');
for (var i = 0; i < l2; i++) {
var val = l1.substr(i, 1);
var name = this.arraySearch(val, PinYinConfig);
if (reg.test(val)) {
I1 += val;
} else if (name !== false) {
I1 += name;
}
}
I1 = I1.replace(/ /g, '-');
while (I1.indexOf('--') > 0) {
I1 = I1.replace('--', '-');
}
return I1;
};
PinYin.prototype.arraySearch = function (l1, l2) {
for (var name in l2) {
if (l2[name].indexOf(l1) != -1) {
return this.ucfirst(name);
break;
}
}
return false;
};
PinYin.prototype.ucfirst = function (l1) {
if (l1.length > 0) {
var first = l1.substr(0, 1).toUpperCase();
var spare = l1.substr(1, l1.length);
return first + spare;
// return first;
}
}
/**
* 获取汉字首字母
* @param {any} 中文字符串
* @return 拼音首字母串数组
*/
PinYin.prototype.makePy = function (str) {
if (typeof (str) != "string")
throw new Error(-1, "函数makePy需要字符串类型参数!");
var arrResult = new Array(); //保存中间结果的数组
for (var i = 0, len = str.length; i < len; i++) {
//获得unicode码
var ch = str.charAt(i);
//检查该unicode码是否在处理范围之内,在则返回该码对映汉字的拼音首字母,不在则调用其它函数处理
arrResult.push(this.checkCh(ch));
}
//处理arrResult,返回所有可能的拼音首字母串数组
return this.mkRslt(arrResult);
}
PinYin.prototype.checkCh = function (ch) {
var uni = ch.charCodeAt(0);
//如果不在汉字处理范围之内,返回原字符,也可以调用自己的处理函数
if (uni > 40869 || uni < 19968)
return ch; //dealWithOthers(ch);
//检查是否是多音字,是按多音字处理,不是就直接在strChineseFirstPY字符串中找对应的首字母
return (oMultiDiff[uni] ? oMultiDiff[uni] : (strChineseFirstPY.charAt(uni - 19968)));
}
PinYin.prototype.mkRslt = function (arr) {
var arrRslt = [""];
for (var i = 0, len = arr.length; i < len; i++) {
var str = arr[i];
var strlen = str.length;
if (strlen == 1) {
for (var k = 0; k < arrRslt.length; k++) {
arrRslt[k] += str;
}
} else {
for (var k = 0; k < arrRslt.length; k++) {
arrRslt[k] += str.charAt(0);
}
/* var tmpArr = arrRslt.slice(0);
arrRslt = [];
for (k = 0; k < strlen; k++) {
//复制一个相同的arrRslt
var tmp = tmpArr.slice(0);
//把当前字符str[k]添加到每个元素末尾
for (var j = 0; j < tmp.length; j++) {
tmp[j] += str.charAt(k);
}
//把复制并修改后的数组连接到arrRslt上
arrRslt = arrRslt.concat(tmp);
}*/
}
}
return arrRslt.length != 0 ? arrRslt[0]:null;
}
String.prototype.trim = function (arr) {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
var PinYin = new PinYin();
exports("pinyin", PinYin);
});