Skip to content

Commit

Permalink
Patches blank to tab (overtrue#55)
Browse files Browse the repository at this point in the history
* 汉字拼音字典打patch的时候,增加兼容性,空格转为tab,统一起来

* 字典中空格转为统一的tab【\t】

* 空格替换为tab
  • Loading branch information
aizuyan authored and overtrue committed Jun 13, 2016
1 parent 33dfc0f commit 5e12584
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 4 additions & 4 deletions data/words_1
Original file line number Diff line number Diff line change
Expand Up @@ -3401,7 +3401,7 @@
'阿佤' => ' a wǎ',
'阿卡' => ' a kǎ',
'哦呀' => ' ò yā',
'曾姓' => ' zēng xìng',
'曾姓' => ' zēng xìng',
'巴阿' => ' bā a',
'腌臜' => ' ā zā',
'子儿' => ' zǐ r',
Expand All @@ -3427,7 +3427,7 @@
'吖吖' => ' ā ā㐀',
'呃呃' => ' e e',
'壳儿' => ' ké r',
'便宜' => ' pián yí',
'便宜' => ' pián yí',
'囮子' => ' é zǐ',
'阿堵' => ' ē dǔ',
'阿坝' => ' a bà',
Expand All @@ -3442,7 +3442,7 @@
'阿苏' => ' a sū',
'阿谀' => ' ē yú',
'阿里' => ' a lǐ',
'姓曾' => ' xìng zēng',
'姓曾' => ' xìng zēng',
'阿附' => ' ē fù',
'啊哈' => ' ā hā',
'抹额' => ' mò é',
Expand Down Expand Up @@ -4528,7 +4528,7 @@
'参与' => ' cān yù',
'发卡' => ' fà qiǎ',
'眼泡' => ' yǎn pāo',
'曾家' => ' zēng jiā',
'曾家' => ' zēng jiā',
'牛只' => ' níu zhī',
'为重' => ' wéi zhòng',
'调羹' => ' tiáo gēng',
Expand Down
12 changes: 11 additions & 1 deletion tools/dict_gen
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ echo "\nbuild combine ...";
exec('cat '.__DIR__.'/chars.dat >> '.__DIR__.'/words.dat');
echo "Done.";
$words = [];
$lines = array_merge(file(__DIR__.'/words.dat'), file(__DIR__.'/patches/words.txt'));

//这里对patches words.txt中拼音可能的空格转化为换行符
$patch_words = file(__DIR__.'/patches/words.txt');
foreach($patch_words as &$patch_word) {
list($word, $pinyin) = explode(",", trim($patch_word));
$pinyin = preg_replace("/\s+/", "\t", $pinyin);
$patch_word = $word . "," . $pinyin;
}
unset($patch_word);

$lines = array_merge(file(__DIR__.'/words.dat'), $patch_words);

foreach ($lines as $line) {
list($word, $pinyin) = explode(",", trim($line));
Expand Down

0 comments on commit 5e12584

Please sign in to comment.