if (limit <= 0) limit = Integer.MAX_VALUE;
// compute frequencies of distinct terms
HashMap<String,MutableInteger> map = new HashMap<String,MutableInteger>();
TokenStream stream = analyzer.tokenStream("", new StringReader(text));
TermAttribute termAtt = stream.addAttribute(TermAttribute.class);
try {
while (stream.incrementToken()) {
MutableInteger freq = map.get(termAtt.term());
if (freq == null) {
freq = new MutableInteger(1);