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.
27 lines
545 B
27 lines
545 B
9 months ago
|
from cppy.cp_util import *
|
||
|
|
||
|
|
||
|
# 框架类
|
||
|
class TFFlowcls:
|
||
|
def __init__(self, v):
|
||
|
self._value = v
|
||
|
|
||
|
def bind(self, func):
|
||
|
self._value = func(self._value)
|
||
|
return self
|
||
|
|
||
|
def over(self):
|
||
|
print(self._value)
|
||
|
|
||
|
|
||
|
def top10_freqs(word_freqs):
|
||
|
top10 = "\n".join(f"{word} - {count}" for word, count in word_freqs[:10])
|
||
|
return top10
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
TFFlowcls( testfilepath )\
|
||
|
.bind(extract_file_words)\
|
||
|
.bind(get_frequencies)\
|
||
|
.bind(sort_dict)\
|
||
|
.bind(top10_freqs)\
|
||
|
.over()
|