From e7087ceb62f26c74460519ff7afd60fb9c7300b9 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Sat, 5 Nov 2011 11:47:55 +0800 Subject: improves gen special table --- scripts/genspecialtable.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/genspecialtable.py b/scripts/genspecialtable.py index a53be7a..c7384b5 100644 --- a/scripts/genspecialtable.py +++ b/scripts/genspecialtable.py @@ -68,9 +68,17 @@ def gen_resplit_table(): (orig_first_key, orig_second_key, new_first_key, new_second_key) = map\ (get_chewing_string, (orig_first_key, orig_second_key, \ new_first_key, new_second_key)) - entry = '{{{0}, {1}, {2}, {3}, {4}, {5}}}'.format \ - (orig_first_key, orig_second_key, orig_freq, \ - new_first_key, new_second_key, new_freq) + if new_freq > orig_freq: + if orig_freq == 0: + benefit = 0.5 + else: + benefit = 0.3 + elif orig_freq >= new_freq: + assert orig_freq > 0, "Expected orig_freq > 0 here." + benefit = 0 + entry = '{{{0}, {1}, {2}, {3}, {4}}}'.format \ + (orig_first_key, orig_second_key, \ + new_first_key, new_second_key, benefit) entries.append(entry) return ',\n'.join(entries) -- cgit