14.10.08

just show words

This code, put into Processing, shows you the words that are in my blog.
It looks for the things that separate words, and then spits them out.

As it's reading an RSS feed it often spits out some HTML but that not really a problem, i just need it to be aware of where a word ends and begins.


//i'm now trying to break the script down more, as i don't want it to tell me how many times it finds the word, i only want it to show me it.

PFont f; //holds onto the font
String[] fiosblog; //array to hold onto the text in my blog
int counter = 150; //where to start in the text

//delimiters (stuff that breaks up the words)
String delimiters = " ,.?!;:[]";

void setup() {
size(400,400);

f = loadFont( "Dialog-32.vlw" ); //loads the font

//this bit imports my blog anf makes it into a array of strings
String url = "http://fionnualamurphy.blogspot.com/feeds/posts/default";
String[] rawtext = loadStrings(url);

//join the strings back together, into one long string
String everything = join(rawtext, "" );

// the big string now needs to be split into individual words
//using splitTokens() a spaces and punctuation are the delimiters.
fiosblog = splitTokens(everything, delimiters);
frameRate(5);
}

void draw() {
background(255);

//pick a word
String theword = fiosblog[counter];

//Display results
textFont(f);
fill(0);
text(theword,10,90);
stroke(0);
fill(175);


//move onto next word
counter = (counter +1) % fiosblog.length;
}



I've basically just taken this code by Daniel Shiffman and edited it so it only presents me with the word.

I've got it separating words, now i just need it to start recognizing them. I think that's going to be the hard bit.

No comments: