summaryrefslogtreecommitdiffstats
path: root/scripts2/doublepinyintable.py
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2015-09-07 14:44:23 +0800
committerPeng Wu <alexepico@gmail.com>2015-09-07 14:44:23 +0800
commita44728667329e19418cc9fa28a0dd63e8a1ce9bb (patch)
tree79a2a85a44d348f091a308c533361d1cca8ca189 /scripts2/doublepinyintable.py
parent58ceaafb09440502c0a30895cf2ca4447cc2323d (diff)
downloadlibpinyin-a44728667329e19418cc9fa28a0dd63e8a1ce9bb.tar.gz
libpinyin-a44728667329e19418cc9fa28a0dd63e8a1ce9bb.tar.xz
libpinyin-a44728667329e19418cc9fa28a0dd63e8a1ce9bb.zip
import doublepinyintable.py from gendoublepinyinheader.py
Diffstat (limited to 'scripts2/doublepinyintable.py')
-rw-r--r--scripts2/doublepinyintable.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts2/doublepinyintable.py b/scripts2/doublepinyintable.py
new file mode 100644
index 0000000..8c78353
--- /dev/null
+++ b/scripts2/doublepinyintable.py
@@ -0,0 +1,71 @@
+# -*- 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+from doublepinyin import SHUANGPIN_SCHEMAS
+
+
+def gen_shengmu_table(scheme):
+ entries = []
+ #select shengmu mapping
+ sheng = SHUANGPIN_SCHEMAS[scheme][0]
+ for c in "abcdefghijklmnopqrstuvwxyz;":
+ sh = sheng.get(c, "NULL")
+ if sh != "NULL":
+ sh = '"{0}"'.format(sh)
+ entry = '{{{0: <5}}} /* {1} */'.format(sh, c.upper())
+ entries.append(entry)
+ return ',\n'.join(entries)
+
+
+def gen_yunmu_table(scheme):
+ entries = []
+ #select yunmu mapping
+ yun = SHUANGPIN_SCHEMAS[scheme][1]
+ for c in "abcdefghijklmnopqrstuvwxyz;":
+ y = yun.get(c, ("NULL", "NULL"))
+ if len(y) == 1:
+ y1 = y[0]
+ y2 = "NULL"
+ else:
+ y1, y2 = y
+ if y1 != "NULL":
+ y1 = '"{0}"'.format(y1)
+ if y2 != "NULL":
+ y2 = '"{0}"'.format(y2)
+ entry = '{{{{{0: <7}, {1: <7}}}}} /* {2} */'.format(y1, y2, c.upper())
+ entries.append(entry)
+ return ',\n'.join(entries)
+
+
+'''
+def get_table_content(tablename):
+ (scheme, part) = tablename.split('_', 1)
+ if part == "SHENG":
+ return gen_shengmu_table(scheme)
+ if part == "YUN":
+ return gen_yunmu_table(scheme)
+'''
+
+
+### main function ###
+if __name__ == "__main__":
+ pass