from cppy.cp_util import * def extractWords(path_to_file): assert(type(path_to_file) is str), "Must be a string" assert(path_to_file), "Must be a non-empty string" return extract_file_words(path_to_file) def frequencies(word_list): assert(type(word_list) is list), "Must be a list" assert(word_list != []), "Must be a non-empty list" return get_frequencies(word_list) def sort(word_freqs): assert(type(word_freqs) is dict), "Must be a dictionary" assert(word_freqs != {}), "Must be a non-empty dictionary" return sort_dict(word_freqs) if __name__ == '__main__': try: word_freqs = sort(frequencies(extractWords( testfilepath ))) print_word_freqs(word_freqs) except Exception as e: print(" Something wrong: {0}".format(e) )