summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-23 11:21:22 +0800
committerPeng Wu <alexepico@gmail.com>2011-11-23 11:21:22 +0800
commit0ae49515d539175b888fbd3420908b949c6cae21 (patch)
tree10d48223d1cfb1f9e41697e490a3d203cec33062
parent56abe0fc75529b7b3c054ca900ed28c3a33d08d0 (diff)
downloadlibpinyin-0ae49515d539175b888fbd3420908b949c6cae21.tar.gz
libpinyin-0ae49515d539175b888fbd3420908b949c6cae21.tar.xz
libpinyin-0ae49515d539175b888fbd3420908b949c6cae21.zip
fixes gen bopomofo header
-rw-r--r--scripts/chewing_table.h.in33
-rw-r--r--scripts/genbopomofoheader.py29
2 files changed, 52 insertions, 10 deletions
diff --git a/scripts/chewing_table.h.in b/scripts/chewing_table.h.in
index de8247f..ac01a3a 100644
--- a/scripts/chewing_table.h.in
+++ b/scripts/chewing_table.h.in
@@ -6,20 +6,37 @@
namespace pinyin{
-const chewing_scheme_item_t chewing_standard[] = {
-@STANDARD@
+const chewing_symbol_item_t chewing_standard_symbols[] = {
+@STANDARD_SYMBOLS@
};
-const chewing_scheme_item_t chewing_ginyieh[] = {
-@GINYIEH@
+const chewing_tone_item_t chewing_standard_tones[] = {
+@STANDARD_TONES@
};
-const chewing_scheme_item_t chewing_eten[] = {
-@ETEN@
+
+const chewing_symbol_item_t chewing_ginyieh_symbols[] = {
+@GINYIEH_SYMBOLS@
+};
+
+const chewing_tone_item_t chewing_ginyieh_tones[] = {
+@GINYIEH_TONES@
+};
+
+const chewing_symbol_item_t chewing_eten_symbols[] = {
+@ETEN_SYMBOLS@
+};
+
+const chewing_tone_item_t chewing_eten_tones[] = {
+@ETEN_TONES@
+};
+
+const chewing_symbol_item_t chewing_ibm_symbols[] = {
+@IBM_SYMBOLS@
};
-const chewing_scheme_item_t chewing_ibm[] = {
-@IBM@
+const chewing_tone_item_t chewing_ibm_tones[] = {
+@IBM_TONES@
};
};
diff --git a/scripts/genbopomofoheader.py b/scripts/genbopomofoheader.py
index 9a204e4..2ed613e 100644
--- a/scripts/genbopomofoheader.py
+++ b/scripts/genbopomofoheader.py
@@ -34,6 +34,9 @@ bopomofo = [
'ˊ', 'ˇ', 'ˋ', '˙',
]
+#陰平聲不標號
+num_tones = -4
+
bopomofo_keyboards = {
#標準注音鍵盤
'STANDARD':
@@ -72,8 +75,10 @@ def escape_char(ch):
return "'{0}'".format(ch)
-def gen_chewing_keyboard(scheme):
+#generate shengmu and yunmu here
+def gen_chewing_symbols(scheme):
keyboard = bopomofo_keyboards[scheme]
+ keyboard = keyboard[: num_tones]
items = []
for (i, key) in enumerate(keyboard):
items.append((key, bopomofo[i]))
@@ -87,8 +92,28 @@ def gen_chewing_keyboard(scheme):
return ",\n".join(entries)
+#generate tones here
+def gen_chewing_tones(scheme):
+ keyboard = bopomofo_keyboards[scheme]
+ keyboard = keyboard[num_tones:]
+ items = []
+ for (i, key) in enumerate(keyboard, start=2):
+ items.append((key, i));
+ items = sorted(items, key=itemgetter(0))
+ entries = []
+ for (key, tone) in items:
+ key = escape_char(key);
+ entry = "{{{0: <5}, {1}}}".format(key, tone)
+ entries.append(entry)
+ return ",\n".join(entries)
+
+
def get_table_content(tablename):
- return gen_chewing_keyboard(tablename)
+ (scheme, part) = tablename.split('_', 1)
+ if part == "SYMBOLS":
+ return gen_chewing_symbols(scheme);
+ if part == "TONES":
+ return gen_chewing_tones(scheme);
def expand_file(filename):