|
ML Assignment: Pig Latin
Fall 2000, David Matuszek, Villanova
University
|
Your assignment is to write an ML function latinize
S to translate an
English sentence S (represented as a string) into Pig Latin.
For example,
- latinize "when the cats away the mice
will play";
> "enwhay ethay atscay awayhay ethay icemay illway ayplay"
The rules for translating into Pig Latin are:
- If a word begins with a vowel, add "
hay" to the
end of the word. For example, "apple" becomes
"applehay." (One dialect uses
"yay" rather than "hay;" if you would
rather do it this way, that's fine too.)
- If a word begins with one or more consonants, move those
initial consonants to the end of the word and add
"
ay." For example, "strength"
becomes "engthstray."
Simplifying assumptions:
- Don't worry about capital letters; everything can be
lowercase.
- Don't use any punctuation.
- Use single spaces to separate words.
- Always treat "y" as a consonant.
Hints:
- ML is interactive; play with it. Get used to it a little
before you try to do any serious work. This will help a lot when
you try to actually start using it.
- "A Gentle Introduction to ML" is quite good; read it and try
the online quizzes.
- Write little functions, one at a time, and test each one out
before writing the next one. (This is a good technique in any
language.)
- If you can't keep your functions small, at least build them up
and test them a line or two at a time. Otherwise you'll have a big
function with an error in it somewhere that you just can't
find.
Extra credit:
- Handle capital letters correctly, e.g.
"When..."
becomes "Enwhay..."
- Retain the punctuation used in the original.
Turn in:
- A floppy with a proper label on it, and your name on the
label, containing the program in a file named
pig.sml. You can include a file named
Readme.txt if there is anything in particular you
want to tell us about.
- No paper.
Due dates: Monday, December 11 and Wednesday, December 13.