@@ -0,0 +1,985 @@
+package multeval.util;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0A%0Aimport com.google.common.collect.Multiset;%0Aimport com.google.common.collect.Multiset.Entry;%0A%0Apublic class CollectionUtils %7B%0A%0A%09// rom%0A%09// http://philippeadjiman.com/blog/2010/02/20/a-generic-method-for-sorting-google-collections-multiset-per-entry-count/%0A%09public static %3CT%3E List%3CEntry%3CT%3E%3E sortByCount(Multiset%3CT%3E multiset) %7B%0A%0A%09%09Comparator%3CMultiset.Entry%3CT%3E%3E occurence_comparator = new Comparator%3CMultiset.Entry%3CT%3E%3E() %7B%0A%09%09%09public int compare(Multiset.Entry%3CT%3E e1, Multiset.Entry%3CT%3E e2) %7B%0A%09%09%09%09return e2.getCount() - e1.getCount();%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09List%3CEntry%3CT%3E%3E sortedByCount = new ArrayList%3CEntry%3CT%3E%3E(multiset.entrySet());%0A%09%09Collections.sort(sortedByCount, occurence_comparator);%0A%0A%09%09return sortedByCount;%0A%09%7D%0A%0A%09public static %3CT%3E List%3CT%3E head(List%3CT%3E list, int n) %7B%0A%09%09if (n %3C= list.size()) %7B%0A%09%09%09return list.subList(0, n);%0A%09%09%7D else %7B%0A%09%09%09return list;%0A%09%09%7D%0A%09%7D%0A%7D%0A

Support for OOV feature