import requests from cppy.cp_util import * def main(): # 读测试文件的内容 content = read_file() # 抽词 tokenize_response = requests.post("http://localhost:7770/tokenize", json={"text": content}) words = tokenize_response.json()["words"] # 计算词频 count_response = requests.post("http://localhost:7771/count", json={"words": words}) word_count = count_response.json()["word_count"] # 排序 sort_response = requests.post("http://localhost:7772/sort", json={"word_count": word_count}) top_10_words = sort_response.json()["top_10_words"] print("Top 10 words:") print_word_freqs(top_10_words) if __name__ == "__main__": main()