You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
749 B

8 months ago
from cppy.cp_util import *
8 months ago
class Flow:
8 months ago
def extract_file_words(self, filepath):
self.data = extract_file_words(filepath)
return self
8 months ago
def get_frequencies(self):
self.data = get_frequencies(self.data)
return self
8 months ago
def sort_dict(self):
self.data = sort_dict(self.data)
return self
8 months ago
def print_word_freqs(self, n):
print_word_freqs(self.data, n)
return self
# 顺序调用
Flow().extract_file_words(
testfilepath).get_frequencies().sort_dict().print_word_freqs(10)
8 months ago
'''
连续方法调用看起来比较舒服
但是需要假设
- 每一个类方法返回 self 否则没法连续
- 类方法默认不写第一个参数数据都在 .data 里面
'''