summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-02-21 11:10:46 +0800
committerPeng Wu <alexepico@gmail.com>2013-02-21 11:18:44 +0800
commit7dfc18b954da70f977c8b272503dd34df042419b (patch)
treeacaff9da9ddceebf5a0a9d7c0edb6ca20e825e0e
parent8280f39b9e4c765d50029c034d07f775900d1657 (diff)
downloadlibpinyin-7dfc18b954da70f977c8b272503dd34df042419b.zip
libpinyin-7dfc18b954da70f977c8b272503dd34df042419b.tar.gz
libpinyin-7dfc18b954da70f977c8b272503dd34df042419b.tar.xz
add shengmu and yunmu to content_table
-rw-r--r--scripts/genpinyintable.py15
-rw-r--r--src/storage/pinyin_parser2.h2
2 files changed, 16 insertions, 1 deletions
diff --git a/scripts/genpinyintable.py b/scripts/genpinyintable.py
index 6eda276..cc60034 100644
--- a/scripts/genpinyintable.py
+++ b/scripts/genpinyintable.py
@@ -58,11 +58,24 @@ def sort_all():
pinyin_index = sorted(pinyin_index, key=sortfunc)
bopomofo_index = sorted(bopomofo_index, key=sortfunc)
+def get_sheng_yun(pinyin):
+ if pinyin == None:
+ return None, None
+ if pinyin == "":
+ return "", ""
+ if pinyin == "ng":
+ return "", "ng"
+ for i in range(2, 0, -1):
+ s = pinyin[:i]
+ if s in shengmu_list:
+ return s, pinyin[i:]
+ return "", pinyin
def gen_content_table():
entries = []
for ((correct, bopomofo, chewing)) in content_table:
- entry = '{{"{0}", "{1}", {2}}}'.format(correct, bopomofo, chewing)
+ (shengmu, yunmu) = get_sheng_yun(correct)
+ entry = '{{"{0}", "{1}", "{2}", "{3}", {4}}}'.format(correct, shengmu, yunmu, bopomofo, chewing)
entries.append(entry)
return ',\n'.join(entries)
diff --git a/src/storage/pinyin_parser2.h b/src/storage/pinyin_parser2.h
index 644dd07..e40b30c 100644
--- a/src/storage/pinyin_parser2.h
+++ b/src/storage/pinyin_parser2.h
@@ -31,6 +31,8 @@ namespace pinyin{
typedef struct {
const char * m_pinyin_str;
+ const char * m_shengmu_str;
+ const char * m_yunmu_str;
const char * m_chewing_str;
ChewingKey m_chewing_key;
} content_table_item_t;