Skip to content

Commit

Permalink
增加一些缺失的拼音
Browse files Browse the repository at this point in the history
  • Loading branch information
macroxue committed Jan 8, 2024
1 parent d29ba38 commit ebaef51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
20 changes: 15 additions & 5 deletions evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ function all_pinyin_to_key_strokes(sheng_yun_key_map) {
key_pinyin_map[conversion.key_strokes] = all_pinyin[i];
} else {
error += all_pinyin[i] + '和' + existing_pinyin + '都是' +
conversion.key_strokes + '\n';
conversion.key_strokes.toUpperCase() + '\n';
}
}
return {pinyin_key_map: pinyin_key_map, error: error};
Expand All @@ -469,7 +469,8 @@ function convert_text_to_key_strokes(scheme_name, scheme) {
// Convert characters to key strokes.
var input = document.getElementById('input-text').value;
var key_strokes = '';
var ignored = '';
var ignored_chars = new Set();
var ignored_pinyins = new Set();
for (var i = 0; i < input.length; ++i) {
var c = input[i].trim();
if (c == '') {
Expand All @@ -482,12 +483,21 @@ function convert_text_to_key_strokes(scheme_name, scheme) {
}
var pinyin = char_pinyin[c];
if (pinyin == null) {
ignored += c;
ignored_chars.add(c);
continue;
}
if (!(pinyin in pinyin_key_map)) {
ignored_pinyins.add(pinyin);
continue;
}
key_strokes += pinyin_key_map[pinyin];
}
// console.log('忽略: ' + ignored);
if (ignored_chars.size > 0) {
console.log('忽略的字符: ' + Array.from(ignored_chars).join(''));
}
if (ignored_pinyins.size > 0) {
console.log('忽略的拼音: ' + Array.from(ignored_pinyins).join(','));
}
return {strokes:key_strokes, error:error};
}

Expand Down Expand Up @@ -581,7 +591,7 @@ function show_results(scheme_name) {
var time = result.time;
var speed = hits / time;
var total_distance = result.effective_distance + result.overlap_distance;
set_inner_html('error', result.error);
set_inner_html('error', result.error.trim().replace(/\n/g, ','));
set_inner_html('score', (speed * 100).toFixed(1) + '分');
set_inner_html('hits', hits);
set_inner_html('time', Math.round(time));
Expand Down
14 changes: 10 additions & 4 deletions hanzi_pinyin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var all_pinyin = [
'chong',
'chou',
'chu',
'chua',
'chuai',
'chuan',
'chuang',
Expand All @@ -61,6 +62,7 @@ var all_pinyin = [
'dao',
'de',
'dei',
'den',
'deng',
'di',
'dia',
Expand All @@ -79,13 +81,15 @@ var all_pinyin = [
'e',
'ei',
'en',
'eng',
'er',
'fa',
'fan',
'fang',
'fei',
'fen',
'feng',
'fiao',
'fo',
'fou',
'fu',
Expand Down Expand Up @@ -147,6 +151,7 @@ var all_pinyin = [
'kang',
'kao',
'ke',
'kei',
'ken',
'keng',
'kong',
Expand Down Expand Up @@ -181,10 +186,10 @@ var all_pinyin = [
'lou',
'lu',
'luan',
'lue',
'lun',
'luo',
'lv',
'lve',
'm',
'ma',
'mai',
Expand Down Expand Up @@ -215,7 +220,6 @@ var all_pinyin = [
'nei',
'nen',
'neng',
'ng',
'ni',
'nian',
'niang',
Expand All @@ -228,9 +232,10 @@ var all_pinyin = [
'nou',
'nu',
'nuan',
'nue',
'nun',
'nuo',
'nv',
'nve',
'o',
'ou',
'pa',
Expand Down Expand Up @@ -274,6 +279,7 @@ var all_pinyin = [
'rong',
'rou',
'ru',
'rua',
'ruan',
'rui',
'run',
Expand Down Expand Up @@ -407,5 +413,5 @@ var all_pinyin = [
'zuan',
'zui',
'zun',
'zuo'
'zuo',
];

0 comments on commit ebaef51

Please sign in to comment.