Is there any way to pull the count from a Multiset
into a list?
String[] data = loadStrings("data/data.txt");
Multiset<String> myMultiset = ImmutableMultiset.copyOf(data);
for (String word : Multisets.copyHighestCountFirst(myMultiset).elementSet()) {
System.out.println(word + ": " + myMultiset.count(word));
// ...
}
As it stands I can output the most commonly occurring words into the console in Processing. I was wondering if it is at all possible to add the corresponding words and their count into an array or a list. I have tried like so:
for (String word : Multisets.copyHighestCountFirst(myMultiset).elementSet()) {
float a[] = myMultiset.count(word);
}
but only received errors stating I cannot convert an int
to a float[]
Is this even possible? Am I going about it all wrong? I've never used Multiset
s before so any help would be really useful
UPDATE: I have used this to get a copy of the highest count but am unable to convert it into a list.
Multiset<String> sortedList = Multisets.copyHighestCountFirst(myMultiset);