Thursday, April 12, 2007

The Gettysburg Address: More Fun with Google

This is part three of the continuing series of Gettysburg Address posts (see here and here). I came across a nifty little online tool [link] which automatically searches Google. You type a few words into a box and "the system will search for this sentence at Google, find the next word and print that. Then it will remove the first word of the search string, add the found word and repeat." I wanted to see how good Google is at finding the Gettysburg Address.
Google is actually pretty bad at it. Although it always gets "four score and seven years ago," but then rapidly decays into gibberish. Part of the problem is a Christian rock band called Relient K and their album "Five Score and Seven Years Ago." Typically after the word "ago" "k" appears, and that blows it apart.
Thus, if you start with the feeder phrase "four score and seven years ago our" things pick up. It is able to accurately reproduce the first sentence of the speech. Then it gets distracted by the Declaration of Independence. And then goes on to produce lots of gibberish:
four score and seven years ago our fathers brought forth on this continent, a NEW nation, conceived in Liberty, and dedicated to the proposition that all men are created equal That_ they are endowed by their Creator with certain unalienable rights; that among these are Life, Liberty, and the Pursuit of happiness: in the Workplace. is a serious problem, A Human nature Repair manual. by Dennis Prager Paperback, Jan ISBN

However, tack on "fathers" and you still get the Declaration, however, you also get political commentary, advertisements and cooking advice. And, of course, Gibberish:
four score and seven Years ago our fathers brought forth on this continent, a NEW nation, conceived in Liberty, and dedicated to the proposition that all men are created equal That_ they are endowed by their Creator with certain unalienable rights; that among these are Life, Liberty, and the Pursuit of happiness: The Pursuit of happiness is a most ridiculous phrase: if you pursue happiness you ll never get Rich DVD You Stupid Man DVD- NEW SEALED HOFFMAN DUSTIN. promo. did did did did did you see the words_ Home Page in the Internet zone and the Trusted zone to Medium and add the onion and cook stirring occasionally, until the onion is translucent. Add the garlic and cook for minutes, Add tomatoes with juice) and the Fox s Friends The most important thing in life is to be feared. that the same thing that is a* bit of a Do: k MJnd uæ st~

You can also get it going in an amusing loop, such as repeating instructions. Try some of the first sentence up to, and not including "our." Or just try "did did," for example. Or try your own favorite speech. I'm looking forward to seeing your results in the comments!

4 comments:

  1. I tried seeing how good it was with poetry. I entered the phrase "And did those feet in ancient time" That is the poem that is sung in Monty Python's Mattress sketch, and I always wanted to hear the end of it, seeing as it's such a weird poem and all.

    And boy is it a weird poem:
    "And did those feet in ancient time Walk upon England s mountains green? and was the Holy lamb of God. O LAMB Of god. I come! I come. I come, Just as I am, by- the way, a lot of people have been displaced In the past year By age Group: and Sex. and the City, Stuff Programs did did did did did you see the words_ Home Page in the Internet zone and the Trusted zone to Medium and add the onion and cook stirring occasionally, until the onion is translucent. Add the garlic and cook for minutes, or until the vegetables are tender, Add the sugar and stir until dissolved, Add the orange juice and the high heat flux tests of the small diameter bomb SDB) is a pound did did"

    Oddly enough Eli, it includes your phrase "did did did did did you see the words_ Home Page in the Internet zone and the Trusted zone to Medium and add the onion and cook stirring occasionally,"
    as did many other things we searched from. Now you know where it came from.

    Alas Wikipedia has a slightly less weird version.

    And how about Shakespeare?
    "Shall I compare thee to- a summer s day? Thou art more lovely and more temperate Rough winds do shake the darling buds of May, The Complete Series Special Edition DVD Set! is a must have for_ any airsoft- Guns! This did did did they before we go to the lake. and the impact of the New Media revolution is that, it is not the critic_ who counts; not the man who points out how the strong man stumbled, or where the doer of deeds could have done better. with this one. and I m having"

    It actually did rather well, for a while anyways.

    ReplyDelete
  2. This is a pretty standard markov chaining technique, for those CS people among us. And by 'pretty standard' I mean that it was my second problem set of Intro II. (The intro once you know how to code.)

    The concept of markov k-chain's is that you divide your text corpus into sets of k "words" (in quotation marks b/c punctuation is usually considered a "word"). Once you have this whole list, you can rechain things together with a given amount of overlap. For instance, by digging up this 4 year old problem set and relearning a bit of LISP, I managed to produce the follow speech from Hamlet:

    (EOP FOR THIS RELIEF MUCH THANKS |:| |'TIS| BITTER COLD |,| AND TELL ME |,| HE
    THAT KNOWS |,| WHY THIS SAME STRICT AND MOST OBSERVANT WATCH SO NIGHTLY TOILS
    THE SUBJECT OF THE LAND |,| AND JUMP AT THIS DEAD HOUR |,| WITH HIS LIFE |,|
    ALL THOSE HIS LANDS WHICH HE STOOD SEIZED OF |,| TO THE INHERITANCE OF
    FORTINBRAS |,| HAD HE BEEN VANQUISHER |;| AS |,| BY STRONG HAND AND TERMS
    COMPULSATORY |,| THOSE FORESAID LANDS SO BY HIS FATHER LOST |:| AND THIS |,|
    I TAKE IT |,| IS HORATIO THERE ? EOP BERNARDO HAS MY PLACE |.| GIVE YOU GOOD
    NIGHT |.| IF YOU DO MEET HORATIO AND MARCELLUS |,| THE BELL THEN BEATING ONE
    |,| - - DID SLAY THIS FORTINBRAS |;| WHO BY A MOST EMULATE PRIDE |,| DARED TO
    THE COMBAT |;| IN WHICH THE MAJESTY OF BURIED DENMARK DID SOMETIMES MARCH ?
    BY HEAVEN I CHARGE THEE |,| SPEAK ! EOP BERNARDO HAS MY PLACE |.| GIVE YOU
    GOOD NIGHT |.| IF YOU DO MEET HORATIO AND MARCELLUS |,| THE SOURCE OF THIS
    POST - HASTE AND ROMAGE IN THE LAND |,| AND WILL NOT LET BELIEF TAKE HOLD OF
    HIM TOUCHING THIS DREADED SIGHT |,| TWICE SEEN OF US |:| THEREFORE I HAVE
    SEEN NOTHING |.| EOP WHAT ART THOU THAT |USURP'ST| THIS TIME OF NIGHT |,|
    TOGETHER WITH THAT FAIR AND WARLIKE FORM IN WHICH OUR VALIANT HAMLET - - EOP
    PEACE |,| BREAK THEE OFF |;| LOOK |,| WHERE IT COMES AGAIN ! EOP STAY ! SPEAK
    |,| SPEAK ! EOP SAY |,| WHAT |,| IS HORATIO THERE ? EOP NOT A MOUSE STIRRING
    |.| EOP SIT DOWN |,| AND LET US HEAR BERNARDO SPEAK OF THIS |.| EOP LOOKS IT
    NOT LIKE THE KING ? EOP BEFORE MY GOD |,| I MIGHT NOT THIS SOMETHING MORE
    THAN FANTASY ? WHAT THINK YOU |ON'T| ? EOP BEFORE MY GOD |,| I TAKE IT |,|
    HORATIO |.| EOP HOW NOW |,| SIT WE DOWN |,| AND I AM SICK AT HEART |.| EOP
    GIVE YOU GOOD NIGHT |.| EOP IT WOULD BE SPOKE TO |.| EOP TUSH |,| |'TWILL|
    NOT APPEAR |.| EOP WELL |,| GOOD NIGHT |.| EOP |'TIS| NOW STRUCK TWELVE |;|
    GET THEE TO BED |,| FRANCISCO |.| EOP LOOKS IT NOT LIKE THE KING |THAT'S|
    DEAD |.| EOP HORATIO SAYS |'TIS| BUT OUR FANTASY |,| AND FOREIGN MART FOR
    IMPLEMENTS OF WAR |;| WHY SUCH DAILY CAST OF BRAZEN CANNON |,| AND FOREIGN
    MART FOR IMPLEMENTS OF WAR |;| WHY SUCH IMPRESS OF SHIPWRIGHTS |,| WHOSE SORE
    TASK DOES NOT DIVIDE THE SUNDAY FROM THE POLE HAD MADE HIS COURSE TO ILLUME
    THAT PART OF HEAVEN WHERE NOW IT BURNS |,| MARCELLUS AND MYSELF |,| THE
    RIVALS OF MY WATCH |,| BID THEM MAKE HASTE |.| EOP SEE |,| IT STALKS AWAY !
    EOP BERNARDO HAS MY PLACE |.| GIVE YOU GOOD NIGHT |.| IF YOU DO MEET HORATIO
    AND MARCELLUS |,| THE RIVALS OF MY OPINION |,| THIS BODES SOME STRANGE
    ERUPTION TO OUR STATE |.| EOP
    )

    This comment is too long already; I will continue...

    ReplyDelete
  3. The other half of that assignment, which I am far prouder of, was to define your own grammar. This is completely unrelated to Eli's post, but ridiculously (in my humble opinion) funny. I give you my freshman year BOY BAND LYRICS GENERATOR:

    > (generate 'song)

    YOU CRAVE US

    RAGING WIND ACROSS MY DREAM / YOU SET ME FREE / I SPOKE TOO SOON / I AM CRAZY FOR YOU

    INTERESTING [CLUTCH HEART] / IT IS NOT TOO LATE / [CLUTCH HEART] / I WILL BRING IT BACK TO YOU BABY [REPEAT TO FADE]

    I WILL STAND BY YOUR SIDE / I WILL STAND BY YOUR SIDE / YOU FEEL FOR ME LIKE THE SKY ABOVE / I SUBMIT MY TRUE HEART TO YOUR SEA

    DO DO DO HMMMMMMMM / OOOOH [SCREAM TO SKY] / NA NA NA HMMMMMMMM / I ADORE US LIKE A RIVER / NA NA NA NA NA NA YEAH YEAH YEAH [SCREAM TO SKY] / PASSIONATE

    I AM JEALOUS FOR YOU / I AM JEALOUS FOR YOU / THAT DRESS REALLY DID MAKE YOU LOOK FAT / MY HAIR FALLS OUT WITHOUT YOU

    SNOW AND SALT / HER FLAMING EYES MAKES ME JEALOUS / HMMMMMMMM / WE CAN TURN BACK TIME / I AM GONNA MAKE IT CRAZY / DO DO DO NA NA NA OOOOH [FALL TO KNEES]

    ReplyDelete
  4. ha ha danny, that was pretty cool

    ReplyDelete