}
// It must clear attributes, as it is creating new tokens.
clearAttributes();
final AnalyzedTokenReadings tr = tokenIter.next();
AnalyzedToken at = tr.getAnalyzedToken(0);
// add POS tag for sentence start.
if (tr.isSentStart()) {
// TODO: would be needed so negated tokens can match on something (see testNegatedMatchAtSentenceStart())
// but breaks other cases:
//termAtt.append("SENT_START");
typeAtt.setType("pos");
if (toLowerCase) {
termAtt.append(POS_PREFIX.toLowerCase() + tr.getAnalyzedToken(0).getPOSTag().toLowerCase());
} else {
termAtt.append(POS_PREFIX + tr.getAnalyzedToken(0).getPOSTag());
}
return true;
}
// by pass the white spaces.
if (tr.isWhitespace()) {
return this.incrementToken();
}
offsetAtt.setOffset(tr.getStartPos(), tr.getStartPos() + at.getToken().length());
for (int i = 0; i < tr.getReadingsLength(); i++) {
at = tr.getAnalyzedToken(i);
if (at.getPOSTag() != null) {
if (toLowerCase) {
posStack.push(POS_PREFIX.toLowerCase() + at.getPOSTag().toLowerCase());
} else {
posStack.push(POS_PREFIX + at.getPOSTag());
}
}
}
current = captureState();