static S ngramScoreBySet(int n, S text, Set set1, Set set2, S a, S b) { int score = 0; for (S s : ngrams(n, text)) score += zeroOne(set1.contains(s))-zeroOne(set2.contains(s)); ret score > 0 ? a : score < 0 ? b : null; }