MANGLE!

by Yee Yang Li Hector

Jump to the applet | Mail me


Introduction

Mangle! is a funny AI Java applet that I developed, inspired by an old Scientific American mathematical recreations column. It uses Markov chain probability theory to deconstruct and then reconstruct a body of text. To use it, simply copy and paste into the text box a sufficiently long body of text. Then, press mangle and sit back and enjoy! (You might want the Java Console open to check it's status).

How It Works

The applet first parses through the text, gathering the frequencies of words following two word pairs. Like "The applet" is followed by one instance of "first" in this body of text. Then, it constructs a binary tree of the phrases and a linked list of words that can follow any two word pair. Finally, it picks the first two words of the original text and uses the tree to guess the next word. Then it uses the guess and the second original word to guess the fourth ... much like following the links in a chain. That's why it's called a Markov chain. ;-).

Suggested use

The applet will reconsruct as is, a small body of text. So I would recommended that you use a large piece of text so that it can make use of redundancies to reconstruct a funnier piece of text. Why not try pasting in an e-mail from a friend? (Caution - please include carriage returns in your text)



Mangle Java Applet Source

AITREE Class Source

AILIST Class Source