From 8946f39e2efd7ba25b4364327908c660b1a1204d Mon Sep 17 00:00:00 2001 From: pbr4nzfkh <18879212807@163.com> Date: Wed, 13 Mar 2024 14:19:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=9C=BA=20=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E8=A1=A8=E6=A0=BC=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 基本结构/状态机/81B.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 基本结构/状态机/81B.py diff --git a/基本结构/状态机/81B.py b/基本结构/状态机/81B.py new file mode 100644 index 0000000..1746beb --- /dev/null +++ b/基本结构/状态机/81B.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import cppy.cp_util as util + +# 每一列是一个数据元素和一个公式,第一列是输入数据,所以没有公式 +all_words = [(), None] +non_stop_words = [(), util.extract_str_words] +frequencies = [(), util.get_frequencies] +sorted_data = [(), util.sort_dict] + +# 整个电子表格 +all_columns = [all_words, non_stop_words,\ + frequencies, sorted_data] + +# 每次输入数据后调用此方法 +def update(): + global all_columns + for c in all_columns[1::]: + if c[1] == util.extract_str_words: + c[0] = c[1](all_words[0]) + elif c[1] == util.get_frequencies: + c[0] = c[1](non_stop_words[0]) + elif c[1] == util.sort_dict: + c[0] = c[1](frequencies[0]) + +# 将固定数据加载到第一列中 +all_words[0] = util.read_file(util.testfilepath) +# 调用update函数遍历列表 +update() + +#打印结果 +util.print_word_freqs(sorted_data[0]) + +