From b25143cc438923792c3507264c391dba51c66b1c Mon Sep 17 00:00:00 2001 From: zhiyang7 Date: Wed, 9 Feb 2022 17:59:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 493affb..aaf96aa 100644 --- a/main.py +++ b/main.py @@ -44,9 +44,9 @@ def main(argv): parameter = 'bai vvv vv vvv,012 000 00 000;bai tou er xin,012 010 10 001' mode = '2' parameter = '1234' - mode = '3' - parameter = '风调雨顺 1234,00 00 00 20 1111;无所不包 2341,00 00 00 00 2121;得心应手 2143,01 00 00 20 2222' - num = 100 +# mode = '3' +# parameter = '风调雨顺 1234,00 00 00 20 1111;无所不包 2341,00 00 00 00 2121;得心应手 2143,01 00 00 20 2222' + num = 3 try: opts, args = getopt.getopt(argv, "hm:p:n:", ["mode=", "parameter=", "num="]) except getopt.GetoptError: @@ -111,10 +111,12 @@ def main(argv): break print_max_group(all_idiom, group, num) elif mode == '2': + all_idiom = all_idiom[all_idiom['word'].str.len() == 4] all_idiom['pinyin_tone'] = all_idiom.apply(lambda x: get_tone(x['pinyin']), axis=1) group = all_idiom[all_idiom['pinyin_tone'].str.startswith(parameter)].copy() print_max_group(all_idiom, group, num) elif mode == '3': + all_idiom = all_idiom[all_idiom['word'].str.len() == 4] parameter_rst = parameter.split(';', 1) if len(parameter_rst) > 1: parameter_rst = parameter_rst[1] @@ -129,7 +131,6 @@ def main(argv): parameter = parameter[:-5] hits=hits[:-5] - all_idiom = all_idiom[all_idiom['word'].str.len() == 4] all_idiom['pinyin_tone'] = all_idiom.apply(lambda x: get_tone(x['pinyin']), axis=1) group = all_idiom.copy() while(True):