/**
* Convert from a JCas object into Java Tokenizer object.
*/
public static Token convert(BaseToken bta)
{
Token token = new Token(bta.getBegin(), bta.getEnd());
token.setText(bta.getCoveredText());
if (bta instanceof WordToken)
{
WordToken wta = (WordToken) bta;
token.setType(Token.TYPE_WORD);
switch (wta.getCapitalization())
{
case TokenizerAnnotator.TOKEN_CAP_ALL:
token.setCaps(Token.CAPS_ALL);
break;
case TokenizerAnnotator.TOKEN_CAP_FIRST_ONLY:
token.setCaps(Token.CAPS_FIRST_ONLY);
break;
case TokenizerAnnotator.TOKEN_CAP_MIXED:
token.setCaps(Token.CAPS_MIXED);
break;
case TokenizerAnnotator.TOKEN_CAP_NONE:
token.setCaps(Token.CAPS_NONE);
break;
}
switch (wta.getNumPosition())
{
case TokenizerAnnotator.TOKEN_NUM_POS_FIRST:
token.setNumPosition(Token.NUM_FIRST);
break;
case TokenizerAnnotator.TOKEN_NUM_POS_MIDDLE:
token.setNumPosition(Token.NUM_MIDDLE);
break;
case TokenizerAnnotator.TOKEN_NUM_POS_LAST:
token.setNumPosition(Token.NUM_LAST);
break;
case TokenizerAnnotator.TOKEN_NUM_POS_NONE:
token.setNumPosition(Token.NUM_NONE);
break;
}
}
else if (bta instanceof NumToken)
{
NumToken nta = (NumToken) bta;
token.setType(Token.TYPE_NUMBER);
if (nta.getNumType() == TokenizerAnnotator.TOKEN_NUM_TYPE_INTEGER)
{
token.setIsInteger(true);
}
else
{
token.setIsInteger(false);
}
}
else if (bta instanceof PunctuationToken)
{
token.setType(Token.TYPE_PUNCT);
}
else if (bta instanceof NewlineToken)
{
token.setType(Token.TYPE_EOL);
}
else if (bta instanceof ContractionToken)
{
token.setType(Token.TYPE_CONTRACTION);
}
else if (bta instanceof SymbolToken)
{
token.setType(Token.TYPE_SYMBOL);
}
return token;
}