Koda

About: I am a digital artist and computer geek with interests in Linux, open source design programs, and saving the world. You will find me blogging here about art, life, technology, and other mildly amusing things. More »

English hacking with Python

Python vs. your english teacher!

Apologies for the lack of updates. Over winter break I simply haven’t been able to bring myself to posting here. :-|

No matter! Here’s something I’ve been meaning to share for a while. I know it’s kind of long, but bear with me. It will be worth it. :-D

I am a long time believer in the art of English hacking (or English abuse, if you like). I’ve never taken a formal course on Linguistics or similar topics, but I’ve always had an attraction to messing with bits of the English and seeing what breaks first. For a time, IRC was the
medium of choice. I downloaded a copy of gNiall, and soon became fascinated with it. Essentially, a random phrase generator that knows what words can go after the other, the Niall program because the object of my new obsession. In a short bit of time I had written a Python port of the main AI code (more details at the site). Excited with my achievement, I munged it into an IRC bot and promptly annoyed the hell out of my channel mates. It was beautiful.

I quickly discovered my true calling in this bot-making business: the humor! Every now and then, the bot would say something that would catch us all completely off guard. There’s something incredibly joy-filled and hysterically funny about seeing a piece of code that you put together “say” something… underwhelmingly clever. It’s kind of like readingengrish; it’s funny because it doesn’t make sense! Harken back to the good old days of 2003… X-D

Dec 22 19:17:31 [Chromakode] @niall are you hurt
Dec 22 19:17:32 [itsacowitsafrog] Chromakode: Are you fight.
Dec 22 19:17:40 [chromakode] @niall no, are you ok
Dec 22 19:17:41 [itsacowitsafrog] Chromakode: I robot.
Dec 22 19:17:50 [Chromakode] @niall yes, is the robot ok
Dec 22 19:17:51 [itsacowitsafrog] Chromakode: Yes is the robot.
Dec 22 19:17:56 [Chromakode] @niall is yes ok
Dec 22 19:17:57 [itsacowitsafrog] Chromakode: Im dead.
Dec 22 19:18:00 [Chromakode] @niall crap
Dec 22 19:18:03 [itsacowitsafrog] Chromakode: Crap.

Okay, so maybe it isn’t as funny as I remember, but you have to take my word for it, it was a blast!
In playing with this less-than-intelligent random phrase generator, I became aware of a simple rule in dealing with mangled computer english (call it the law of nonsense): if there is any sane possible interpretation of a sentence, as humans we will fill in the details and context required for it to make sense.

I think within the week that “itsacowitsafrog” was introduced, a channel-wide rule had to be created disallowing bots. Of course that didn’t stop me from playing with it. I threw the Niall engine into a jabber bot and used transports to bring it onto AIM and MSN. The beautiful simplicity of Niall’s design is that by saying things to it, you can be sure that eventually your words will come back to you. I shared it with my friends. Unfortunately, they quickly discovered that any nonsense or profanity they threw at it would be regurgitated back at them in a form even they couldn’t be prepared for.

[22:29:59] [pandas] SMELLY
[22:29:59] [itsacowitsafrog] Smelly.
[22:30:15] [pandas] I AM BRAINWASHED BY CHROMA'S FRIENDS!
[22:30:16] [itsacowitsafrog] And mouthwash today.

Now, it’s no surprise that when you ask any male between the ages of 13 and 25 to talk to say something witty, it becomes a game of naming the reproductive organs. But come on, when 2-3 of my friends spontaneously come to this same conclusion, I really start to wonder. :-|

(19:14:45) Chromakode: why did everyone turn you into a profanity bot?
(19:14:46) itsacowitsafrog: **********.

All your base turned into “all your face”:

(19:45:11) itsacowitsafrog: All your face are you.

Good times. Thing is, it’s glaringly obvious that the Niall engine is really, really dumb. 99% of the time, it would end up spitting out a phrase like "Hello are you pandas rule the world." I blame this partially on the stuff we said to it. Other times, it was funny simply because it was dumb:

(15:33:29) itsacowitsafrog: Fruit pancake.
(15:33:30) Chromakode: whoa!
(15:33:33) itsacowitsafrog: Fruit pancake.
(15:33:35) Chromakode: whoa!
(15:33:37) itsacowitsafrog: Whoa.

I needed something simpler… more clever. Clever enough to slip under the wires and back into the IRC channel. Half a year passed, and an idea presented itself in the form of a message from one friend to another: I swear, everything you said so far has been "lol", "rofl", and "haha" :p.

It’s name was almosthuman, and it did one thing and did it very well: it laughed. (historical: note the noob underscores ;-))

Jun 18 15:53:59 [_Chromakode_] lol
Jun 18 15:54:00 [almosthuman] omg lol!

It was silly. It was evil. It worked. Almosthuman was an experiment in Twisted python and social engineering. After people started interrogating it, I added an ambiguous answer to anything people would say to it:

Jun 18 15:54:01 [Exdaix] almosthuman: I hate you
Jun 18 15:54:02 [almosthuman] i dunno

Over the next few days while almosthuman and I were laughing our asses off, people started to wonder about this character that only said “lol”. I could barely contain myself. Eventually I broke down and admitted its secret. :-)

That was it for the botmaking, at least for a time. I moved on to other distractions, I guess. Until recently. Over winter break I tried out another idea. I was tired of all this resynthesizing sentences business, and decided I needed a way to get ready-made phrases and make them funny. Then it occured to me: what if I took random sentences from my gaim logs, and put them together? Would the law of nonsense apply? Within a few hours and under 60 lines I had some working code, and an answer.

fluffynuts: My book, actually. I have almost 300 pages
funnyface: its the only
fluffynuts: you got bashed?!
funnyface: :P
fluffynuts: I can't read
funnyface: Oh, StarCraft?

Now we were getting somewhere! Okay, so I added a random sophomoric name generator I had lying around, but I felt it fit in so nicely. I ran program over and over again, hungering for the humor and the randomness it promised. I must have spent a few hours just reading random text. Sometimes it was funny simply because I knew it was random. I think what made it so enjoyable was that fact that these were sentences from conversations I remembered having. My gaim logs directory has moved with me from computer to computer, cataloging at least 3 years of my life. There was also the randomness element - I never knew when I would hit paydirt. It came soon enough.

crumpledgout: say if you agree to help me
mooshywok: itsa lie!!!
crumpledgout: are you sad?
mooshywok: all 3

Beautiful. Only a computer could concieve of such brilliant english hackery. “Are you sad? All 3.” Bahahaha. It makes no sense. But then, we don’t want it to, do we? I think I’ve ingrained that sentence into my being, having repeated it to myself so many times. I mean, here’s something that could actually be useful! How many times have you been caught off guard with a sneaky question, when you could have just answered “all 3?” ;-)

I realized that there was a sweet spot for the randomness to be funny. There can’t be too much back and forth, or too little… because then it doesn’t make sense:

bungiefloat: . . . If you say so, I shall just take your word for it.
stonefloat: I think I killed the virus
bungiefloat: i know the pros, i know the cons
stonefloat: Du Cash et des cado ds mon profil !
bungiefloat: :DD:D:D:D
bungiefloat: peanut butter.
stonefloat: I'm a hardcore evo fan though

But if you have just enough and not enough information, the law of nonsense will make it work. Here are some quotes for your enjoyment.

tastefulhair: :(
janglygrape: I'll let you know when I'm back!
tastefulhair: :(
tastefulhair: dammmm
janglygrape: back

mooshybutt: omg
mooshybutt: I'm on a roll :)
yummypsycho: you do aikido?!

dongleface: its tree sap
messytangle: :D
dongleface: at a wedding :P

fluffyface: :)
fluffyface: That thing gets rather monotonous :))
rootbeerfloat: *cries*
fluffyface: too much rich chocolate

tastefulhand: And the profile table, having only 3 columns, can be easily extended by just adding more values.
lumpygrape: hmm... yolks.

lumpygout: ... someone just threw up outside my room
stupidgout: ?
lumpygout: the whole document?
stupidgout: oh, nevermind

crumpledface: SAY IT
stonetangle: got Milk?
crumpledface: I LIKE IT

monkeynuts: But even if I do get famous in a good way, remember that I do, indeed, have many issues. I blame my family, like many do.
fluffygrape: people make fun of your foot

That’s all for now folks! X-D

I hope you’ve enjoyed this excursion into the world of computer-mangled english. My script should work on most Linux computers running gaim. I’m considering expanding it to IRC logs some day…

Now, I will say it again: a good part of the enjoyment is the fact that it’s from your logs. If you’d like to try it out yourself, I’d be happy to share the code with you. I would put it online in the first place, but I don’t really have a place to put it, and the code is still quite hackish. So, send me an email (or some hosting space), and start mangling some english today! :-D

[chromakode]

Comments »

The URI to TrackBack this entry: trackback.

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>