private String extractSingleFeature(int wordId, int field) { String feature; if (tokenInfoBuffer.isPosFeature(field)) { int featureId = tokenInfoBuffer.lookupPosFeature(wordId, field); feature = posValues.get(featureId); } else { int featureId = tokenInfoBuffer.lookupFeature(wordId, field); feature = stringValues.get(featureId); } return feature; }
@Override public String[] getAllFeaturesArray(int wordId) { BufferEntry bufferEntry = tokenInfoBuffer.lookupEntry(wordId); int posLength = bufferEntry.posInfos.length; int featureLength = bufferEntry.featureInfos.length; // TODO: When can posLength be 0? if (posLength == 0) { posLength = bufferEntry.tokenInfos.length - TOKEN_INFO_OFFSET; } String[] result = new String[posLength + featureLength]; for (int i = 0; i < bufferEntry.posInfos.length; i++) { int feature = bufferEntry.posInfos[i] & 0xff; // TODO: This bitwise AND is a no-op... result[i] = posValues.get(feature); } if (bufferEntry.posInfos.length == 0) { posLength = bufferEntry.tokenInfos.length - TOKEN_INFO_OFFSET; for (int i = 0; i < posLength; i++) { int feature = bufferEntry.tokenInfos[i + TOKEN_INFO_OFFSET]; result[i] = posValues.get(feature); } } for (int i = 0; i < featureLength; i++) { int feature = bufferEntry.featureInfos[i]; String s = stringValues.get(feature); result[i + posLength] = s; } return result; }
@Override public int getWordCost(int wordId) { return tokenInfoBuffer.lookupTokenInfo(wordId, WORD_COST); }
@Override public int getRightId(int wordId) { return tokenInfoBuffer.lookupTokenInfo(wordId, RIGHT_ID); }
@Override public int getLeftId(int wordId) { return tokenInfoBuffer.lookupTokenInfo(wordId, LEFT_ID); }