forked from p46318075/CodePattern
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
541 B
27 lines
541 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)
|
||
|
|
||
|
|
||
9 months ago
|
def top_freqs(word_freqs):
|
||
9 months ago
|
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)\
|
||
9 months ago
|
.bind(top_freqs)\
|
||
9 months ago
|
.over()
|