CSC151.02 2003F, Class 14: Talk Like a Pirate Day Admin: * I may be a few minutes late for today's class. * New homework (extension of today's class) * New reading: Repetition with Recursion * Today's goal: Program that turns "landlubber english" into pirate-talk Overview: * Techniques for changing dialect * Specific instances for piratization * Some useful Scheme * Lab What are some general techniques that the Shizzalotor and other services use? * Particular word changes, e.g. "for" to "fo'" * Add some suffixes to sentences, e.g. "... 'n sh*t". * Sometimes letter changes, e.g., "v" to "b" * Removes certain words (e.g., "to") How might we apply these various techniques? * Word changes * "Hello" -> "Ahoy" * "My" -> "Me" * "Woman" -> "Beauty" * "Man" -> "bilge rat" or "scallywag" or "ugly" or ... * Additions to the end of sentence * ", matey" * ", me 'earty" * ". Saavy?" * ", arrhhh." Translator should be comparatively easy: Replace words, Replace ends of sentences Start easy: The one-word-pirate-translator Extend so that it still takes one word as input, but can handle different words Hard part: Going from a long phrase to a set of words. (split "llasdasdfadffa aadsfd") -> list of words (join (" " "asdfas" "asdfas") -> single word We have a list of words and we know how to change individual words Scheme includes "map" for just that purpose. Do the lab. /Reflection/ * Here's an interesting sample phrase (from Kennedy's innaugural address) And so, my fellow Americans: ask not what your country can do for you--ask what you can do for your country. My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man. * A better way to deal with lots of possibilities (list-ref (list "bilge-rat" "landlubber" "mate" "bastard") (random 4)) * How would you write "add the word 'slimy' before some nouns"?