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.
|
|
|
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 top_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(top_freqs)\
|
|
|
|
.over()
|