Slide 16
Slide 16 text
public Pair mostFrequent( String[] words, int threshold)
{
Pair mostFrequent = null;
Map countMap = countWords( words );
for (Map.Entry entry : countMap.entrySet() ) {
if (entry.getValue() < threshold)
continue;
if (mostFrequent == null || entry.getValue() > mostFrequent.second)
mostFrequent = new Pair(entry.getKey(), entry.getValue());
}
return mostFrequent;
}