Homework 2-6

In this homework, you will complete the program that you outlined in the last assignment. As a reminder, this program needs to read text out of a file whose name is given in the command line and count the number of words and sentences in that file.

Task 1: Review your outline

Look over your outline. Do you know what each function should be doing?

Your outline assumed that you would be using the input function to get the filename, but we'd actually like you to get the filename from the command line like you did in the lab.

When counting sentences, we're considering a sentence to be any phrase that ends in a period (.), question mark (?), or exclamation mark(!). Ellipses (...) do not end sentences unless there are four dots (....).

Task 2: Fill in the program

Write code for each function, including your main function. Make sure it matches our style guidelines.

Task 3: Test your code

Test your code on a number of input text files. We've provided the Kung Fu Panda script as an example of realistic input. You should run some smaller examples where you can count words and sentences and confirm that they're correct. Make sure to put your code and your input files in the same directory so Python can find the files.

Think about what kind of text files might be slightly weird and make sure your program can handle it. Can your program handle files that are a single word? a single sentence? Be sure to test your code on input with punctuation other than periods!

You should share at least 3 test cases with us (and feel free to write more than 3)! While simple test cases can be very helpful for testing (and you should write some), we're looking for some of your more complex ones with a good variety of types of punctuation, numbers of words per sentence, and numbers of sentences.

Task 4

At the top of your file, write comments that state the number of hours you worked, whether you went to TA hours, and any collaborators. Note that if you are modifying your skeleton code from hw2-5, you may need to change the answers to this part.

Once you're done, upload your code to your google drive and share it with cs0030handin@gmail.com by midnight, 3/13. Make sure it somewhere includes the number of hours you worked, whether you went to ta hours, and any collaborators. Make sure your submission has your name in the filename: FirstLast_HW2-6.py. (Please rename your file to be 2-6 even if you're using homework 2-5 as a starting point.) “FirstLast” should be replaced with your first and last name or we will take off points. Make sure every task has been completed.Remember to turn in your test cases!