in an RSS feed.
i made this code yesterday, but i didn't think it was finding cheese. i don't know if it was the server being dodgy or if i just didn't let it run long enough, but it is actually finding the word.
//Trying to get it recognizing words.
//Would be nice.
String[] tokens; //array
int counter;
void setup() {
size(100, 100);
//load file and split up words
String[] url = loadStrings("http://fionnualamurphy.blogspot.com/feeds/posts/default");
String allText = join(url, " ");
tokens = splitTokens(allText, " ,.?!:;[]-");
}
//so it's now pulling in that sentence and splitting it up.
void draw() {
background(255);
fill(0);
String s = tokens[counter];
counter = (counter +1) % tokens.length;
//look at the words one at a time please
//is the word there?
if (s.equals("cheese")) {
println("CHEESY!");
} else {
println("no cheese.");
}
}
// trying it out on a RSS feed. actually works!
i've spent most of my day messing around with XML, getting the program to look inside specific tags, which could hopefully speed the whole thing up if i get it working, but at least i have something that works!!!
7.11.08
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment