private void setNumPosition(WordToken wta, String tokenText) { if ( tokenText.isEmpty() ) { // was getting ioobE from tokenText.charAt(..) // Possibilities like this (empty, null) should always be checked // - but I wonder that we get (want) empty tokens at all. // I believe that working with zero-length words is a bug, // and this is not a fix it merely avoids a crash. wta.setNumPosition( TokenizerAnnotator.TOKEN_NUM_POS_NONE ); return; } if (isDigit(tokenText.charAt(0))) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_FIRST); } else if (isDigit(tokenText.charAt(tokenText.length()-1))) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_LAST); } else { boolean containsDigit = false; for (int i=0; i<tokenText.length(); i++) { char ch = tokenText.charAt(i); if (isDigit(ch)) containsDigit = true; } if (containsDigit) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_MIDDLE); } else { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_NONE); } } }
private void setNumPosition(WordToken wta, String tokenText) { if ( tokenText.isEmpty() ) { // was getting ioobE from tokenText.charAt(..) // Possibilities like this (empty, null) should always be checked // - but I wonder that we get (want) empty tokens at all. // I believe that working with zero-length words is a bug, // and this is not a fix it merely avoids a crash. wta.setNumPosition( TokenizerAnnotator.TOKEN_NUM_POS_NONE ); return; } if (isDigit(tokenText.charAt(0))) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_FIRST); } else if (isDigit(tokenText.charAt(tokenText.length()-1))) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_LAST); } else { boolean containsDigit = false; for (int i=0; i<tokenText.length(); i++) { char ch = tokenText.charAt(i); if (isDigit(ch)) containsDigit = true; } if (containsDigit) { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_MIDDLE); } else { wta.setNumPosition(TokenizerAnnotator.TOKEN_NUM_POS_NONE); } } }
wta.setNumPosition(numPos); bta = wta; break;
wta.setNumPosition(numPos); bta = wta; break;