Use of procedures, parameter passing, block structures, data types, arrays, abstract data structures, conditional control, iterative and recursive processes, and input/output in programming solutions to a variety of problems. Prerequisite: None.

Lab 6 - Introduction to Dictionaries - (50 points)



Due date: 4/8/2019

Objectives



  • Using File input/output
  • Practice with lists and dictionaries

Introduction



For this lab, you will analyze a text document and count the number of times every word is seen in that file. You will only analyze text (.txt) files. Your program should be called word_count.py. You can download a collection of text documents here to test your Lab.

  • The file will be provided by the user as a command-line argument (5 points). The program should run as follows
    python3 word_count.py belgravia.txt
  • For the input file process it using the following steps
    • Open the file (5 points)
    • Read the file one line at a time and break it up into individual words. (10 points)
    • For each word, check whether that word already exists in the dictionary. If it doesnt, then add it to the dictionary with a count of 1 as its value. If it exists in the dictionary, then update its value by getting the current value, incrementing it, and storing back the new value into the dictionary. (15 points)
    • Close the file (5 points)
  • When you are done processing all the words in the file, print out all the words that have a value/frequency of 50 or greater and are not in the list of stop words. You can download the list of stopwords here (10 points).

Submitting the Lab



Please turn in the following for the Lab.

  • word_count.py
  • README file