This program takes in a text file and break it up into words.  It then finds, for each word, a different word that sounds like it, and prints them both out.  It’s like a little brother following you around….

Here’s the code:

package misc.rita;

import java.io.IOException;

import rita.RiLexicon;
import rita.RiMarkov;

import a2z.A2ZFileReader;

public class Blm272_Week8_Rita {

//static String content;

public static void main(String[] args) throws IOException {

A2ZFileReader fr = new A2ZFileReader(“data/obama.txt”);

RiLexicon lexicon = new RiLexicon(null);

//String regex = “\\b”;
String[] words = fr.getContent().split(” “);

for (int j = 0; j < words.length; j++){

String content = words[j].toString();
System.out.println(“Content:” + ” ” + content);
//markov.loadString(content, 1);

for (int c = 0; c < 1; c++){
String[] rhymes = lexicon.similarBySound(content);

if (rhymes != null) {
String rhyme = rhymes[(int) Math.random()*rhymes.length];
System.out.println(“Sounds like:” + ” ” + rhyme);

//System.out.println(“Sounds like: ” + rhymes[(int) Math.random()*rhymes.length]);
//for (int r = 0; r < rhymes.length; r++) {
//System.out.println(“Sounds like:” + ” ” + rhymes[r]);
//j++;
//}
}

}

}
}

}

1. What I did last week:

I formatted the screen layout (what info goes where), which in turn helped to clarify some aspects of the user interaction process.  Figured out some of the remaining gameplay (high scores displayed by username, not on rap-by-rap basis).  Thought about how to get people to use it.  Set up a test server space to begin programming.

2. What I intend to do this week:

Organize a group to paper prototype the gameplay – free beer?  The goal is to figure out what will make people want to participate, which right now seems to be the big question.  Make changes to the design based on the observations.

3.  Concerns or unexpected obstacles:

Obviously, I am concerned about solving the motivation question.  My other serious concern is whether I can complete this assignment and my thesis at the same time.

4.  Recent insights or surprises:

Getting people excited about a game on the internet is hard.   Surprisingly hard.

Midterm Visualizations

March 3, 2008

For my A-Z Midterm (and in preparation for my thesis), I did four different visualizations based off the same process of entering a single URL into a page scraper, which in turn generates a text file with the result (a concordance list of the words and how many times they appeared on the page).  These four visualization were generated using the myspace.com homepage.

The four different visualizations make use of this information by reading in the text file and drawing the text in different ways, making use of the text itself, the frequency of the word in the text, the length of the word, and the physical width of the word itself as different variables.

Here are some screen shots:

picture-1.png

picture-2.png

picture-3.png

picture-4.png

Here’s some example code for this last one, just to give an idea:

package concordance.processing;

//import java.awt.Font;
//import java.awt.Graphics;
import java.io.*;
//import java.lang.reflect.Array;
import java.util.*;
import java.util.regex.*;

import a2z.*;
import concordance.processing.Word;
import processing.core.PApplet;
import processing.core.PFont;

public class DrawText4 extends PApplet {

ArrayList words;
PFont f;
float r;

public static void main(String[] args) {
PApplet.main(new String[] {“concordance.processing.DrawText4″});
}

public void setup() {
size(1000,720);
words = new ArrayList();
fillConcordance(“test.txt”);
f = createFont(“Georgia”,64,true);
//textFont(f);

}

public void draw() {
background(50);
//10 boxes along the curve
int totalBoxes = 10;
// We must keep track of our position along the curve
float arclength = 0;

translate(width/2,height/2);
// We’re done, print out contents of Tree!

//System.out.println(“Here are the contents of your tree:”);
//Iterator iterator = words.values().iterator();
Iterator iterator = words.iterator();
r = 160;//values + 1000;
while (iterator.hasNext()) {

Word word = (Word) iterator.next();
println(word.getCount());
r = word.getCount()*100;

String output = word.getWord();
int values = word.getCount();
float length = output.length();

textFont(f, (values*length)*values);
//for (int i = 0; i < output.length(); i++)
//{
// The character and its width
//char currentChar = output.charAt(i);
//float w = textWidth(currentChar);
float w = textWidth(output);

// Each box is centered so we move half the width
arclength += w/2;
// Angle in radians is the arclength divided by the radius
// Starting on the left side of the circle by adding PI
float theta = PI + arclength / r;

pushMatrix();
// Polar to cartesian coordinate conversion
translate(r*cos(theta), r*sin(theta));
// Rotate the box
rotate(theta+PI/2); // rotation is offset by 90 degrees
// Display the character (darker = lower count)
fill(values+w);

text(output,0,0);//random(10),random(180));
popMatrix();
// Move halfway again
arclength += w/2;
//}

r+= 1;

}

noLoop();
}
//}

public void fillConcordance(String path) {
String[] lines = loadStrings(path);
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
String[] stuff = line.split(” “);
Word w = new Word(stuff[0]);
w.setCount(Integer.parseInt(stuff[1]));
words.add(w);
}
}

}