From 083a9fb6a32b1750c0924baf8cee550d75da64c3 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 9 Nov 2011 09:25:18 +0800 Subject: refine python code --- scripts/genpinyintable.py | 7 +++++-- scripts/genspecialtable.py | 13 ++++++------- scripts/specialtable.py | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/genpinyintable.py b/scripts/genpinyintable.py index 9a1a273..eafbf5e 100644 --- a/scripts/genpinyintable.py +++ b/scripts/genpinyintable.py @@ -80,9 +80,12 @@ def gen_bopomofo_index(): return ',\n'.join(entries) +#init code +filter_pinyin_list() +sort_all() + + ### main function ### if __name__ == "__main__": - filter_pinyin_list() - sort_all() s = gen_content_table() + gen_pinyin_index() + gen_bopomofo_index() print(s) diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py index 9abe0e4..0ef9d44 100644 --- a/scripts/genspecialtable.py +++ b/scripts/genspecialtable.py @@ -83,15 +83,14 @@ def gen_resplit_table(): return ',\n'.join(entries) -### main function ### -if __name__ == "__main__": - load_phrase("pinyin2.txt") +#init code, load lists +divided_list = filter_divided() +resplit_list = filter_resplit() +sort_all() - #load lists - divided_list = filter_divided() - resplit_list = filter_resplit() - sort_all() +### main function ### +if __name__ == "__main__": s = gen_divided_table() + '\n' + gen_resplit_table() print(s) diff --git a/scripts/specialtable.py b/scripts/specialtable.py index 6976bb7..acb66cf 100644 --- a/scripts/specialtable.py +++ b/scripts/specialtable.py @@ -103,8 +103,10 @@ def filter_resplit(): new_first_key, new_second_key, new_freq +#init code +load_phrase("pinyin2.txt") + if __name__ == "__main__": - load_phrase("pinyin2.txt") for p in filter_divided(): print (p) for p in filter_resplit(): -- cgit