Basic Techniques Blogpost
by Pete Hindle
As part of my coursework, I’m creating a text analysis tool. The coursework also states that blog posts are part of the working progress. Therefore, if you’re not on my course or working with Processing in some form, I doubt the post would be interesting to you.
What is the best way of storing a number next to a word?
I want to scan through a document and look for specfic words. I’ve stored the words in a string array. I thought that the best way to deal with the storage of the words would be to create a two dimensional array and store the words in the first array, and the amount of the word searched for in the second array.
This is not so good, actually, because I made a fatal misunderstanding about two dimensional arrays. The first array is more like an index, so where I thought I was creating…
word searched for count
(and) (one)
(if) (six)
(or) (two)…
etc
I was actually creating a grid like so…
1 2 3 4 5 6 7 8 9 (number of words in conjoiner)
0 0 0 0 0 0 0 0 0 (first thing)
1 1 1 1 1 1 1 1 1 (second thing)
I’m still not at the stage where I’m understanding what is completely going on, but after a brief chat with Tom Schofield, whose project is doing much the same thing as mine (but perhaps more complicated) he pointed me to some examples in the Orange processing book.
Still not quite getting it to match though. Will have to work on that.
One of the things that I’m worried here is that I’m not getting enough room to play. I’ve come into the project with a defined outcome already, and that means that there is very little exploration. In some ways that is a good thing; I don’t end up messing around with for loops again, but in other ways it’s bad as I don’t get to, say, spend time creating a lovely fading display of all the words in the “pieces” array.
On the other hand, the side project with the buttons has made some forward progress. Using the same void bigtext() that I’ve written for the main project, I’ve linked the program together in a way that allows the buttons to change colour. So far, so plain… but! I’ve also solved the horrible slow text problem.
You see, I had two different types of text font, and I think that was slowing down the program immensely. I might do some tests to work out if this is so, but if it is the case, I might use a png file to generate the larger text wanted for the project, and fade that in and out using transparency.

hey pete
yes i think you may be barking up the wrong tree with a 2d array. the main difference with mine is that i made a class (in your case that would be “words”or summat) and each new object of that class is a specific word eg “and”. within the class it goes through the array one index at a time and if it finds a match increments a total by one. you could then make a function in that class to do whatever it is you want to happen with the count eg display the word and number on screen.
of course im new to this so i may have been talking rot.
hope thats helpful anyway