Returns the next token in the stream, or null at EOS.
// if we already returned the edge n-gram, we are done
if (started)
return null;
if (!started) {
started = true;
char[] chars = new char[1024];
input.read(chars);
inStr = new String(chars).trim(); // remove any trailing empty strings
inLen = inStr.length();
}
// if the input is too short, we can't generate any n-grams
if (gramSize > inLen)
return null;
if (side == Side.FRONT)
return new Token(inStr.substring(0, gramSize), 0, gramSize);
else
return new Token(inStr.substring(inLen-gramSize), inLen-gramSize, inLen);