Skip to content

other tools: “knowledge cuts” with Processing and RiTa

August 8, 2010

I’ll teach, for knowledge cuts me!
Would of bitterness all my thinking.

Stand still young maiden to subscribe thy bidding,
  you like a bold, one in this,
  The One dares the hand!

Do thy faith to say, you again quiet.
Have you have much too?
From Heaven befell us, around me,
  And temper the vaulted ceiling creep,
  the book!
  Things are loftier, answer me!
  Come in vain to God!


August 8, supervised generation from bigrams, text: Faust by Goethe, generator: Processing/RiTa.

So I learned Basic on a TI-99/4A when I was a kid, but it wasn’t really an obsession, you know, it was just another toy. Then in college I took Fortran (the lecture was delivered by videotape lol). I took Pascal too, but it was so boring I just turned in the programs if they compiled, I didn’t care too much if they did what they were supposed to.

Anyway, I never really got into programming til the web took off. Then, like a lot of people, I learned HTML and JavaScript by looking at source, copying it into your own files, and checking it out on a web browser. Then when you got it right you could upload it and the whole world could see it. All of a sudden it was fun.

I think that’s what Processing is going for. You basically get a textpad with a ‘Run’ button. So you just type some code in there, press ‘Run’, and an applet appears. Once you get something you like, you can just export it and upload it to a web page.

On its own, Processing looks like it’d be great for those animated poems where text is moving around and making noises. I’m not into that sort of thing, so I haven’t tried it myself, but it looks like it. Luckily Processing makes it easy to develop libraries for it, and some dude developed the RiTa library, which has a number of language-processing methods, including one to create language models and generate poetry using n-grams.

So basically:
size(380, 500); // sets the size of the applet
RiMarkov markov = new RiMarkov(this, 2); // specifies the type of n-gram (bigram = 2)
markov.loadFile(“lovecraftBibleGibbons.txt”); // reads the file to create the language model
String[] lines = markov.generateSentences(10); // generates 10 sentences
RiText[] rts = RiText.createLines(this, lines, 20, 50, 60); // puts the sentences in the applet

so what you do now is look through the examples, pull out the code that looks like it might be relevant, drop it into a simple program like the one above, and keep messing with it til it works. kind of a creative style of learning, huh?

anyway, if you’re at all interested in doing some simple programming, even if you don’t know that much about coding, I suggest you give Processing/RiTa a try. Just download Processing, then download RiTa, then look at some examples and then start mixing and extending the examples to make fun things happen.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: