diff options
author | Peng Wu <alexepico@gmail.com> | 2011-10-25 15:10:02 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-10-25 15:10:02 +0800 |
commit | cfa83483dae050b6010f9de0f9fef8b76501f520 (patch) | |
tree | 7411903647d13c338cf9081f8b322787779b2b14 | |
parent | 0cf993ec98d7f25475bd1c1a8266e5822caeb5f9 (diff) | |
download | libpinyin-cfa83483dae050b6010f9de0f9fef8b76501f520.tar.gz libpinyin-cfa83483dae050b6010f9de0f9fef8b76501f520.tar.xz libpinyin-cfa83483dae050b6010f9de0f9fef8b76501f520.zip |
begin to write special table
-rw-r--r-- | scripts/genspecialtable.py | 43 | ||||
-rw-r--r-- | scripts/pinyin.py | 18 |
2 files changed, 55 insertions, 6 deletions
diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py new file mode 100644 index 0000000..bc92d0b --- /dev/null +++ b/scripts/genspecialtable.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# vim:set et sts=4 sw=4: +# +# libpinyin - Library to deal with pinyin. +# +# Copyright (C) 2011 Peng Wu <alexepico@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import sys +import pinyin + +pinyin_list = sorted(pinyin.PINYIN_LIST) +shengmu_list = sorted(pinyin.SHENGMU_LIST) +yunmu_list = sorted(pinyin.YUNMU_LIST) + +def get_all_special(): + for p in pinyin_list: + if p[-1] in ["n", "g", "r"]: + for yun in yunmu_list: + if yun not in pinyin_list: + continue + new_pinyin = p[-1] + yun + # if new_pinyin in pinyin_list: + yield p, yun, p[:-1], new_pinyin + elif p[-1] in ["e"]: + yield p, "r", p[:-1], "er" + +if __name__ == "__main__": + for pinyins in get_all_special(): + print (pinyins) diff --git a/scripts/pinyin.py b/scripts/pinyin.py index a3eccdb..517d59d 100644 --- a/scripts/pinyin.py +++ b/scripts/pinyin.py @@ -121,9 +121,6 @@ PINYIN_DICT = { PINYIN_LIST = PINYIN_DICT.keys () -ID_PINYIN_DICT = {} -for pinyin, id in PINYIN_DICT.items (): - ID_PINYIN_DICT[id] = pinyin SHENGMU_DICT = { "b" : 1, "p" : 2, "m" : 3, "f" : 4, "d" : 5, @@ -131,13 +128,22 @@ SHENGMU_DICT = { "j" : 12, "q" : 13, "x" : 14, "zh" : 15, "ch" : 16, "sh" : 17, "r" : 18, "z" : 19, "c" : 20, "s" : 21, "y" : 22, "w" : 23 } + SHENGMU_LIST = SHENGMU_DICT.keys () -ID_SHENGMU_DICT = {} +YUNMU_DICT = { + "a" : 1, "ai" : 2, "an" : 3, "ang" : 4, "ao" : 5, + "e" : 6, "ei" : 7, "en" : 8, "eng" : 9, "er" : 10, + "i" : 11, "ia" : 12, "ian" : 13, "iang" : 14, "iao" : 15, + "ie" : 16, "in" : 17, "ing" : 18, "iong" : 19, "iu" : 20, + "o" : 21, "ong" : 22, "ou" : 23, "u" : 24, "ua" : 25, + "uai" : 26, "uan" : 27, "uang" : 28, "ue" : 29, "ui" : 30, + "un" : 31, "uo" : 32, "v" : 33, "ve" : 34 +} + +YUNMU_LIST = YUNMU_DICT.keys () -for shengmu, id in SHENGMU_DICT.items (): - ID_SHENGMU_DICT[id] = shengmu MOHU_SHENGMU = { "z" : ("z", "zh"), |