MCS-177 Project 4: Pig Latin Revisited (Spring 2017)

Start: Tuesday March 14; Due: Saturday March 18, 10pm


Overview

In this project, you will build on your work from the prior project. Instead of just translating individual words between Pig-Latin and English, you will translate entire strings of words. For example, you will translate 'this is Pig Latin' into 'is-thay is-ay ig-Pay atin-Lay' or vice versa. Note that you don't need to handle punctuation marks.

You are to do this project individually.

Splitting words apart and joining them back together

The string method split (see the textbook page 127) will be very useful in this project.

Task 1

  1. Write a procedure, joinWords, for joining a list of words into a single string, where every two consecutive words are separated by a given separator string. It should take in two parameters, a list of strings and a separator (which is a string object). It returns a string of the words separated by the separator string.

    Don't worry about treating punctuation marks or commas or other special characters. You may want to look back to the procedure IntegerBars which you wrote for Project 2. Finally, be sure to consult the grading rubric.

  2. Test your joinWords procedure and fix it if it doesn't work. The following are a few examples:

            >>> joinWords(['this', 'is', 'Pig', 'Latin'], ' ')
            'this is Pig Latin'
            >>> joinWords(['Latin'], '!')
            'Latin'
            >>> joinWords([], '!')
            ''
            >>> joinWords(["I", "like", "Python"], "???")
            'I???like???Python'
            >>> joinWords(["Accumulator", "pattern", "is", "the", "best"], "++")
            'Accumulator++pattern++is++the++best'
            >>> joinWords(['1', '22', '500'], '|')
            '1|22|500'
            >>> joinWords(['1', '22', '500'], '')
            '122500'
    

Task 2

  1. Write a procedure, unPig, for converting a string consisting of space-separated words from Pig Latin to English. For example, unPig('is-thay is-ay ig-Pay atin-Lay') should return 'this is Pig Latin'.

    Don't worry about strings that are fancier than just space-separated words, such as those containing commas. Be sure to consult the grading rubric.

  2. Test your unPig procedure and fix it if it doesn't work. The following are a few examples:

  3.         >>> unPig('is-Thay is-ay e-shay')
            'This is she'
            >>> unPig('is-thay is-ay ig-Pay atin-Lay')
            'this is Pig Latin'
            >>> unPig("ig-Pay atin-Lay")
            'Pig Latin'
            >>> unPig("-Shhay ou-yay")
            'Shh you'
            >>> unPig('atin-Lay')
            'Latin'
            >>> unPig('')
            ''
    

Task 3

  1. Write an analogous procedure, pig for converting a string of English words into Pig Latin. This ought to be a simple matter of copying, pasting, and making a couple very minor changes. You should copy and paste your pigWord and findVowel functions from Project 3. You should use descriptive names for parameters and variables in your procedure.

  2. Test your pig procedure and fix it if it doesn't work.

Submitting your work

Submit your code using Moodle; click on the following link for instructions on submitting code using Moodle. For this project, you will need to submit one Python file called

project4.py
which contains:

Be sure to include all other procedures called by your functions above (for example, if your functions call unPigWord, findVowel, and pigWord), then you have to include these as well, otherwise your functions would not work.

Grading Rubric

The grader will test your program against various input values. Check your work against the grading rubric project4gradesheet.pdf which the grader will use when grading your lab.