I have problem iterating through String Array with table.matchRows command. I got the constructor from
here but it doesn't seem to work. The APlett says "Can only iterate over an array of an instance of jave.lnag.iteravle
Here is the code. The error occur on the line 68. I'm trying to count the repetitions of the same words in the text snatch from Reuters XML.
Please assist.
XML xml;
String[] news = new String[10]; // <<< initiate global arrayList instead
ArrayList<String>wrd = new ArrayList(); // Declare Array List
//int[] reps = new int[1000]; // nubmers 10 (the number of news) and 1000 (the number of words)
I implemented arrayList to store Strings down the code. I didn't know the size so instead pure Array I implemented the list. I was looking for the way to convert objects from the arrayList to Strings and found
how convert the Object to String. At the line 34 PApplet gives me a message "cannot convert from Object[] to String[].
I'm trying sort out the words from XML feed and analyze vocabulary. Could you please help me with arrayList converting.
XML xml;
String[] news = new String[10]; // <<< initiate global arrayList instead
ArrayList wrd = new ArrayList<String>();
int[] reps = new int[1000]; // nubmers 10 (the number of news) and 1000 (the number of words)
int index = 0;
String exceptionWords = "-,of,the";
String[] junctions = split(exceptionWords, ",");
void setup() {
xml = loadXML("http://www.reuters.com/rssFeed/topNews"); // Adress of XML
XML channel = xml.getChild("channel"); // Getting into the channel of the XML
XML[] items = channel.getChildren("item/description"); // Gets into item and then in item gets into description
//String[] news;
for (int i = 0; i < items.length; i++) { // iterate through all elements "description"
//println(items[i].getContent()); // Prints the content of the element "description"
news[i]=(items[i].getContent()); // Record news into the GLOBAL String array
}
//println(news);
String words = join(news, ' '); // Join all elements of the array "news" into a single String
String[] wordsArray = split(words, " "); // Create array of words from the text "news"