CIS200: Assignment 3
10 points. Due Saturday, February 16, 2008, 10:00pm

Pig-Latin is a kind of ``jive talk'' that was popular in the 1930s and 1940s. An English word is translated into Pig-Latin by moving all its leading consonants to the end of the word and attaching ``ay'' to the end. For example, My dog has fleas! becomes
ymay ogday ashay easflay!
(pronounced ''eye-may og-day as-shay ees-flay'' --- Pig-Latin is most entertaining when spoken quickly --- try it)

When a word begins with a vowel, then no leading consonants are moved, and instead, ''shay'' is attached to the end of the word. For example, I bought it on Ebay, yesterday. becomes

ishay oughtbay itshay onshay ebayshay, esterdayyay.
Young people used rapidly spoken Pig-Latin as a code language that adults could not understand.

Assignment

You must write an English-to-Pig-Latin translator, which translates one English sentence to its Pig-Latin equivalent, like we saw in the previous examples:
> python Piglatin.py
Please type an English sentence: This is a test,  I guess, of the program!!
The PigLatin translation is: 
isthay isshay ashay esttay,  ishay uessgay, ofshay ethay ogrampray!!

Press Enter to quit
The program's input is an English sentence, typed one a single line of text. Standard punctuation, is allowed, but contractions ("don't") and possessives ("it's") are not. (Remember that every English sentence ends with a punctuation symbol.) The program's output is the sentence, reformatted as Pig Latin. Notice that all the letters in the output sentence are in lower case and that all the spacing and punctuation are preserved.

Algorithm

The program should first read the input sentence and then play a kind of repetitive ``game'' with the letters in the sentence:
  1. Look at the letters one by one, collecting them into a word, until a space or punctuation symbol is seen.
  2. Next, take the word that was collected and look at its leading letters one by one, trying to find the first vowel in the word. (Remember --- every English word has one or more vowels.) Once the vowel is located, move the letters preceding it (namely, the leading consonants) to the end of the word, followed by ay. (If the word's first letter is a vowel, then append shay to the end.)
  3. Add the translated word to the end of an ``answer sentence'' that you are building. Add the punctuation symbol to the answer sentence.
After you have collected and translated all the words in the sentence, you can print the answer sentence.

Remember that the vowels in English are a,e,i,o,u. The letter y is sometimes a vowel, too. We will use this rule: If y is the first letter of a word (e.g., "yes") it is a consonant, otherwise it is a vowel (e.g., "cry").

Here are some string operations that will be useful:

See the Lecture notes, Chapter 4, for examples of these operations.

Testing

Make certain your program correctly translates words that begin with 0 consonants, 1 consonant, 2+ consonants. Check that punctuation is correctly preserved in the correct positions in the answer sentence.

Submit:

By the submission deadline, use the web page at http://www.cis.ksu.edu/~schmidt/200s08/Assign to submit your file, Piglatin.py.

Reminder: This is a single-person assignment. You are welcome to discuss the assignment with your instructors, tutors, and other students, but the algorithm you design and the program you write and submit must be your own work, just as if you are submitting an essay for an English Composition course.