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()