Programming Assignment 08
"Oneyay allsmay epstay orfay anmay."

Objective: Get more practice with Strings, looping, and files

Due: Wednesday, April 23rd, 10:00 A.M.

 

An introduction

In this PA you will be writing the code for a project which will help us convert words/sentences from English to traditional "Pig Latin." 

 

Pig Latin?

Some of you may have played with Pig Latin as a kid.  There are many slightly different rule sets for Pig Latin.   The version we will use is:

 

The Final Project

Eventually I want you to have code that will take an entire text file and convert it to Pig Latin.  For example, the code that I wrote to test this out myself took the following file

and translated it to this file

[NOTE : for ease of use I have elected to not use any newline characters in these files.  This is probably not realistic in the long run, but it will help you do this assignment for now]

 

However, if you simply start with that idea than you are likely to get confused and run into problems.  Instead, let's think about this problem from the top down.  Our full blown project should:

  1. Open/read a text file
  2. Break the file into one sentence from the file at a time
  3. Break each line/sentence into individual words
  4. For each word, convert it into PigLatin...
  5. by finding the first vowel (if it exists)
  6. And finally, writing these converted words back out to a second text file.

As I look at this project, we want to do this in several manageable steps

 

Part A - (Step 5) Finding the first vowel

Begin by writing a method called findFirstVowel().

 

Part B - (Step 4) Translating one word

Next, write a method called translateWord()

 

Part C - (Step 3) Translating one sentence

Next write a method called translateSentence(). 

Part D - (Steps 1 and 2) Reading from a file

Next, write a method called translateFile()

For testing purposes at this point you can simply print the results to the screen

Part E - (Step 6) Writing to a file

Modify the  translateFile() method

 

Final Submission

As is normal, please prepare all of this in a file called pa08.py and located in a directory called pa08 in your root directory on the p: drive.

Prepare a paper printout of your code to submit at the start of class.