For my first Python program that mashes up text, I chose to work with corporate mottos. I first manually copied over 400 corporate mottos from this pdf file into a text file. I then used Adam’s Cowboy.py program, which replaces common words (you, I, the, etc) with cowboy slang. However, I chose to replace those words with California slang (dude, hella, totally, whatever, etc).
Here is the text replacement program:
|
import sys for line in sys.stdin: line = line.strip() line = line.replace("the ", "hella ") line = line.replace("and ", "like yeah, ") line = line.replace(" a ", " like whatever ") line = line.replace("!", ". Dude.") line = line.replace(",", " totally ") print line |
And a few examples of the result with this initial translation:
- Ace is hella place for hella helpful hardware man.
- Snap. Dude. Crackle. Dude. Pop. Dude.
- Billions like yeah totally  billions served. Dude.
- All hella news that’s fit to print. Dude.
→ Read more