Bag<String> wordFrequencies = getWordFrequencies(text);
我如何看到这个单词包含的内容... 我用过 org.apache.commons.collections15.Bag org.apache.commons.collections15.bag.HashBag包
答案 0 :(得分:2)
public static String bagToString(Bag<?> bag) {
StringBuilder sb = new StringBuilder();
for (Object o : bag.uniqueSet() {
sb.append(o);
sb.append(":");
int nItems = bag.getCount(o);
sb.append(nItems);
sb.append(" ");
}
return sb.toString();
}