Token tok = correction.getOriginal();
// we are replacing the query in order, but injected terms might cause
// illegal offsets due to previous replacements.
if (tok.getPositionIncrement() == 0)
continue;
collation.replace(tok.startOffset() + offset, tok.endOffset() + offset,
correction.getCorrection());
offset += correction.getCorrection().length()
- (tok.endOffset() - tok.startOffset());
}
return collation.toString();