예제 #1
0
  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;
  }
예제 #2
0
  @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;
  }
예제 #3
0
 @Override
 public int getWordCost(int wordId) {
   return tokenInfoBuffer.lookupTokenInfo(wordId, WORD_COST);
 }
예제 #4
0
 @Override
 public int getRightId(int wordId) {
   return tokenInfoBuffer.lookupTokenInfo(wordId, RIGHT_ID);
 }
예제 #5
0
 @Override
 public int getLeftId(int wordId) {
   return tokenInfoBuffer.lookupTokenInfo(wordId, LEFT_ID);
 }