This is my first ever question, apologies for any mistakes I make while asking for help!
I am trying to sort the 5 most repeated words from a text file in Processing and I'm confused about this error I keep getting. I'm new to Java and after searching the internet, any changes I make are not appear to be helping. What do I need to do to amend to fix the issue?
Here is the code in question -
import java.util.Iterator;
import com.google.common.collect.ImmutableMultiset;
import com.google.common.collect.Multiset;
import com.google.common.collect.Multisets;
void setup() {
size(800, 480);
smooth();
String[] data = loadStrings("data/data.txt");
ImmutableMultiset<String> myMultiset = ImmutableMultiset.copyOf(data);
top = Multisets.copyHighestCountFirst(myMultiset);
}
Iterator it = top.entrySet().iterator();
for (int i = 0; (i < 5) && it.hasNext(); i++) {
Multiset.Entry entry = (Multiset.Entry) it.next();
String word = (String) entry.getElement();
int count = entry.getCount();
System.out.println(word + " -> " + count);
}
Thank you kindly in advance for the help!!