The Parodist: A SQL Server Application

Every year, we ask Phil Factor to celebrate the holiday season with an article on SQL Server Programming that is fun. This year, he responded with 'The Parodist'. This is a SQL Server application, the like of which I doubt if you've seen before.

The Parodist, which I’ll be describing here, is a small database application that creates parodies of whatever book you feel inclined to feed into it. I offer you this little script for your amusement as a Christmas present. It may even deliver you your next homework essay in postmodernism, or your next marketing White-paper.

This could be quite a productivity tool. Who would quarrel with these profound words about XML and PHP?

An element may also be defined using annotated schema. A plan is expensive or inexpensive. The feature can be indexed. The best choice of XML Data type still remains.

Complete each box for two expressions that are simple to implement. When your data is highly structured, XML data for example, users may want to use the INSERT workload and between 10 and 2. The LSNs still exist in a PHP resource corresponding to the change table after the load on the production workload.

You can refer to the subtype table has a very simple example and it is divided in groups of 64K records called a segment. Note the first and last names of actual companies and products mentioned herein may be used in Example: View and a set is best introduced by contrasting it with a sum measure on the XML schema collection myCollection” within relational schema for your business needs. None of these conditions are true:

For more information about thread settings In addition to that log records to be configured at the leaves and aggregate several partitions at the time of the sections Relevant Wait Types for Subscriptions SQL Server 2008 Analysis Services will scan and aggregate the segments of one partition at a small number of concurrent threads that perform the SWITCH. Optionally a primary key from the example below.

… except that it is gibberish produced by The ‘Parodist’. Still, it is compelling gibberish, isn’t it.

This might look to you something like Homer’s Iliad, but it isn’t ….

Nor yet e’en so Achilles let his counsel take
who should strike the bird
As less in skill not one was absent;
nor of his lofty vessel’s prow The dark whirlwind’s force
as this wine we pour their hearts’ best blood
Theirs and their fam’d Allies Who freely in thy house
receiv’d For twenty days the heav’nly Maid Daughter of Cisseus
sage Antenor’s wife By Trojans built of fir-trees fell’d
and overlaid the roof With rushes mown from off a fly;
Its course she so directed that it struck but drove not through
For near the warlike Mysians next Antilochus From Mermerus and Phalces
stripp’d their armour spoil’d shalt make thy pray’r

I seem to be in the habit of producing frivolous applications at this time of year. Once, I did a SQL Server version of the classic ‘Waffle Generator’. Several readers asked for something just as clever but less restricting, so that one could get waffle from any text. Fine, I thought, time to implement a finite-state Markov chain with stationary transition possibilities. Actually, the process isn’t as scary as the name. The algorithm was described in 1948, long before personal computers, by Claude Shannon, first in The Bell System Technical Journal, Volume XXVII, No. 3 & 4, and then in The Mathematical Theory of Communication ( ISBN: 9780252725487). The best description I know of is in Jon Bentley’s ‘Programming Pearls’, in the chapter ‘Strings of Pearls’.

It may seem surprising that a technique like this preceded the Age of Information Technology, but we were aware of them whilst they were too long-winded to implement by a manual process. One of the great experiences of IT in the 1970s was the sheer pleasure of trying out ideas that were known about, but were impractical until computers were cheap enough to have in the home. With pencil and paper, these were mere party games, but with computers, they became algorithms.

If you had the patience of a saint, you could do this manually. You would open a book at random, put your finger on the page randomly, and track along to the start of the next sentence, You have the starting word of a sentence: Then, you would find the second word in another sentence that started with that initial word. Once you had the third word, by proceeding likewise, you would be ready to start. You find, at random, a sentence containing the previous two words, adjacent and in the same order; and you take this third word and append it. As authors tend to have mannerisms, and use favourite phrases, this technique seems to pick them up: One gets clichés strung together. The more text you have the better the parody. with small amounts, it just sticks to the sentences it selects, but the richer the text bank, the more creative it gets. See what it does with Mark Twain’s Huckleberry Finn

“Why it’s perfectly ridiculous, but I couldn’t cut the bullet and twice I seen where one of his pocket. Then it was here again for I was used to rip around so and swallow the sawdust so it was about done loading and pretty soon I noticed the king made me creep.

They was off working for the fields; and Jim’s eyes bugged out and says: “Why yonder he is, and if we’d a’ whooped him over to t’other village without any handle; and a roundabout and pants of his father would die first”. But Tom said “Now for the shore, a little twenty-foot yard. My! you ought to seen old Henry the Eight; when he said the duke’s room, and hustling away and leave my sisters with them”. A witch PIE in Jim’s pan and we got some of the river but didn’t look at it. What could he ever undertook that Tom and I’ll do it. “

You might have thought that such a powerful parodist as this would consist of a great deal of code. No, actually, it doesn’t because it is doing what SQL Server does best, which is to search and sort vast quantities of data. So without further introduction here is the code, which should speak for itself. You can find the original source in the downloads at the bottom of the article.

If you need any more convincing, here is Shakespeare, put through the mangle

“Here’s ado to make my peace. I pray you tarry; longer I shall make it flame again; for more I prithee more. As by his small light of discretion that he should escape; For though she’s as fartuous a civil doctor which did put his cause being her uncle Rivers; Talk’d how I do not know DROMIO OF SYRACUSE. My lord Northumberland What says his Majesty bade me from the rebels.

In honest civil godly company for speedy aid; wherein our dearest friend Prejudicates the business is not a son being twain. These are they. Ay sir; a word I pray. Enough sweet Suffolk thou torment’st thyself; And I am glad I am not well; What has he that did haunt me still. Take that winter kill it.

Mine such as doth an inland man; one fire drives out one fire; one nail, one nail, one nail; Rights by me be brief my practice quit his pain. No leisure had he none but libertines delight in them is hereabout And cannot help him; young and though his false finger have profan’d the ring And look upon The Queen; come not by But stay here for defence For courage mounteth with occasion.

Love they flatter me; that can I fortune to the Capitol. Peter didst ever hear better. That will not be wink’d at how shall I be afeard. Pardon dear madam. But if he were dead I’ll speak with Coriolanus.

And what about Brer Rabbit?

“Folks tell um fer me bittle. Whar I ain’t gwine ter stan’ inside en Brer Rabbit he tuck’n stan’ on one side. What are they going to Uncle Remus’s anger was all pretence but he wuz gwine long down de road. I done say I got you dis night en ef you’d a’ bin mighty smart man.

Dat’s so en Brer Rabbit he kotch holt er de flo’ un git all de folks on dis a-way you’ll des keep yo’ eye on de trees look like it mought work. I wonder who put um in de min’ Brer Wolf run fas’ Brer Rabbit en Mr.Man cut tree down. Skin swink skin stink skin swivel. Wid dat Brer Rabbit sezee w’ich ef he don’t year no complaints fum me.”

So I leave you to do your own experimentation, fuelled perhaps from  the vast banks of text in Project Gutenberg, or the rich comedy of marketing papers.  Make sure that it consists of  pure sentences terminated by full-stops (periods). Take out all extraneous text. Try experiments such as mixing two different authors. Why not change the algorithm, or try another variation of the Markov algorithm. After all, SQL Server Developments can, and occasionally should, be fun.