private void processNode(
      SentenceParser.Node node,
      List<String> sentence,
      List<String> tags,
      List<String> target,
      String inheritedTag) {
    String phraseTag = getChunkTag(node);

    boolean inherited = false;
    if (phraseTag.equals(OTHER) && inheritedTag != null) {
      phraseTag = inheritedTag;
      inherited = true;
    }

    TreeElement[] elements = node.getElements();
    for (int i = 0; i < elements.length; i++) {
      if (elements[i].isLeaf()) {
        boolean isIntermediate = false;
        String tag = phraseTag;
        SentenceParser.Leaf leaf = (SentenceParser.Leaf) elements[i];

        String localChunk = getChunkTag(leaf);
        if (localChunk != null && !tag.equals(localChunk)) {
          tag = localChunk;
        }

        if (isIntermediate(tags, target, tag) && (inherited || i > 0)) {
          isIntermediate = true;
        }
        if (!isIncludePunctuations()
            && leaf.getFunctionalTag() == null
            && (!(i + 1 < elements.length && elements[i + 1].isLeaf())
                || !(i > 0 && elements[i - 1].isLeaf()))) {
          isIntermediate = false;
          tag = OTHER;
        }
        processLeaf(leaf, isIntermediate, tag, sentence, tags, target);
      } else {
        int before = target.size();
        processNode((SentenceParser.Node) elements[i], sentence, tags, target, phraseTag);

        // if the child node was of a different type we should break the chunk sequence
        for (int j = target.size() - 1; j >= before; j--) {
          if (!target.get(j).endsWith("-" + phraseTag)) {
            phraseTag = OTHER;
            break;
          }
        }
      }
    }
  }
 protected String getChunkTag(SentenceParser.Leaf leaf) {
   String tag = leaf.getSyntacticTag();
   if ("P".equals(tag)) {
     return "VP";
   }
   return null;
 }
  protected void processLeaf(
      SentenceParser.Leaf leaf,
      boolean isIntermediate,
      String phraseTag,
      List<String> sentence,
      List<String> tags,
      List<String> target) {
    String chunkTag;

    if (leaf.getFunctionalTag() != null && phraseTag.equals(OTHER)) {
      phraseTag = getPhraseTagFromPosTag(leaf.getFunctionalTag());
    }

    if (!phraseTag.equals(OTHER)) {
      if (isIntermediate) {
        chunkTag = "I-" + phraseTag;
      } else {
        chunkTag = "B-" + phraseTag;
      }
    } else {
      chunkTag = phraseTag;
    }

    sentence.add(leaf.getLexeme());
    if (leaf.getSyntacticTag() == null) {
      tags.add(leaf.getLexeme());
    } else {
      tags.add(ADChunkSampleStream.convertFuncTag(leaf.getFunctionalTag(), false));
    }
    target.add(chunkTag);
  }