The script itself (do with it what you will -- should come up with some amusing results for any large text file, whether authored by Mark Morford or anyone else):
import sys, random #usage: #morfordizer.py sourcefile paragraphCount def Canonical(aString): return aString.strip().lower() def SafeAdd(theDict, theKey, theValue): try: theDict[theKey].append(theValue) except: theDict[theKey] = [theValue] infile = open(sys.argv[1], 'r') outfile = open('morfordizer.txt', 'w') theText = infile.read() paragraphTarget = int(sys.argv[2]) for i in range(0, 2): theText = theText.replace(' ', ' ') wordList = theText.split(' ') wordDict = {} for i in range(0, len(wordList) - 1): curWord = Canonical(wordList[i]) nextWord = wordList[i + 1] SafeAdd(wordDict, curWord, nextWord) SafeAdd(wordDict, Canonical(wordList[-1:][0]), wordList[0]) paraCount = 0 curWord = random.sample(wordList, 1)[0] while 1 == 1: print curWord outfile.write(curWord + ' ') curWord = random.sample(wordDict[Canonical(curWord)], 1)[0] if curWord.find('\n') > -1: paraCount += 1 print "*****" + str(paraCount) if paraCount == paragraphTarget: print "\nDone." breakThe poem the Morfordizer made (with some editorial assistance):
Imagine it? What a thing. It's true. No sobering up. A whitewashed wall or even more pliable, amenable, full of this parrot. A chicken-mole burrito in your youth. And the mind, it doth reeled. Did you get dunked in intimate holy matrimony? Hell, yes. Rather, it's in the Arab media? Two minutes with very moment. Try to be punished by the homophobes and arrows of magic elixir to see the fiery tragic demise of ... what does. Suddenly finding Osama bin Laden just the ticket -- and I'm a country where you gullible, timid voters more than help ease the glorious soiling of the hands-down worse environmental president who follows the times as you a current disease and the good porn and that never before the nation that very close to become a down and Stanford and raving then, shrug. policy wonking, childish little detached from Bush's mile-high ream of Congress, she noticed the time to forget how this is how you gag. Shudder. That jerknose Kerry. What are a helluva lot of quirk and a USB cable and true intimate wonderland of lackeys to turn the language at an enormous war in town to ride on with, you own spirit is how you can all a fiery, inseparable part of mutilated corpses of Congress and discover the full of a down payment on an enormous national Guard, which is, apparently, a "Hell yeah"? Whoops, sorry. And a November win? What else fails, well, then, let me a devoted, long-standing clientele as the news with actual photos of the timepiece currently adorning their sexuality, their devout conversations, I know if BushCo has so high you get to launch war on the headlines, dust off my mouth whenever I mention one who wasn't all those titles. The Carlyle Group breathing space and choke. I was doing as they pay him extra just imagine. What inspired act, healthy and Edwards-like. This is it, but also them see the blood and dangerous. Go ahead, Google any substantive, comprehensible, entertaining, humorous, intelligent way. The divine love-drunk revolution, but the driveway, we all about new rallying cry. If all feels, somehow, different. You know they're piloting a drain and demanded the infamous, insulting "Mission accomplished." Ahmed Chalabi. Steel tariffs. The time to look at every generation needs one in the sensation that a while you are now, I am, despite all of oh wait. The country where we've forgotten, amidst the film ever made. You know the positive or your boy certainly didn't know how you -- they define and gnarled conservative sexual matters like changing the altar of Osama by so obviously a place, a speechwriter for war hawks and her lesbian-fantasy thing. Instead allowing the global community of the walls, and more sadistic. Or, rather, it's enough to peel 'em all those marriages, strip away from playing poker with the sea change in an even bothered to dress up until he have their own riveting, galvanizing acceptance speeches at every generation that place, a sitting president in Babeland, as usual. Yes, you in all surprisingly intact, no jurisdiction over the moral terrorist. You mind as a dramatic change the frayed ragtag fundamentalist antiporn crusader attorney general who isn't one.