Example #1
0
  private void initializeFeaturePathInfoFrom(FeaturePathInfo aFp, String[] featurePathString)
      throws AnalysisEngineProcessException {

    try {
      if (featurePathString.length > 1) {
        aFp.initialize(featurePathString[1]);
      } else {
        aFp.initialize("");
      }
    } catch (FeaturePathException e) {
      throw new AnalysisEngineProcessException(e);
    }
  }
Example #2
0
  private List<String> createStringList(List<AnnotationFS> tokens, String[] segments)
      throws AnalysisEngineProcessException {

    List<String> tokenStrings = new ArrayList<String>();
    tokenStrings.add(SENTENCE_START);

    FeaturePathInfo fp = new FeaturePathInfo();
    initializeFeaturePathInfoFrom(fp, segments);

    for (AnnotationFS annotation : tokens) {
      String value = fp.getValue(annotation);
      if (!StringUtils.isBlank(value)) {
        if (toLowercase) {
          value = value.toLowerCase();
        }
        tokenStrings.add(value);
      }
    }

    tokenStrings.add(SENTENCE_END);

    return tokenStrings;
  }