import string from operator import itemgetter def add_word(word_map word): """Adds a word to the dictionary specified (word_map) and increments it's value of occurence. Args: word_map: A dictionary containing words. word: the word to be added. Returns: Void. """ # If the word does not exist in the dictionary it is added # as of the file. Returns: A file object that represents the opened document. """ try: in_file = open(file_name "r") except IOError: print("\n*** unable to open file ***\n") in_file = None return in_file word_map = dict() file_name = input("Enter the file name: ") in_file = open_file(file_name) if in_file is not None: build_map(in_file word_map) display_map(word_map) in_file.close() [...]
This assignment focuses on the implementation of Python programs to read files and process data by using lists and functions.