double product(TokenizedCharSequence thatDoc) { double sum = 0.0; for (String token : mTokenCounter.keySet()) { int count = thatDoc.mTokenCounter.getCount(token); if (count == 0) continue; // tf = sqrt(count); sum += tf1 * tf2 sum += Math.sqrt(count * mTokenCounter.getCount(token)); } return sum; }