Example usage for edu.stanford.nlp.trees Tree toStringBuilder

List of usage examples for edu.stanford.nlp.trees Tree toStringBuilder

Introduction

In this page you can find the example usage for edu.stanford.nlp.trees Tree toStringBuilder.

Prototype

public StringBuilder toStringBuilder(StringBuilder sb) 

Source Link

Document

Appends the printed form of a parse tree (as a bracketed String) to a StringBuilder .

Usage

From source file:elkfed.ml.svm.SVMLightInstanceWriter.java

License:Apache License

public int writeTree(StringBuilder sb, Instance inst) {
    int nTreeFeatures = 0;
    for (int i = 0; i < _fds.size() - 1; i++) {
        switch (_fds.get(i).type) {
        case FT_TREE_STRING:
            sb.append(" ");
            writeBT(sb);/*from   w  w w.  ja  v  a 2  s . c o  m*/
            String valS = (String) inst.getFeature(_fds.get(i));
            if (valS == null)
                sb.append(" ");
            else
                sb.append(valS);
            nTreeFeatures++;
            break;
        case FT_TREE_TREE:
            sb.append(" ");
            writeBT(sb);
            Tree valT = (Tree) inst.getFeature(_fds.get(i));
            if (valT == null)
                sb.append(" ");
            else
                valT.toStringBuilder(sb);
            nTreeFeatures++;
            break;
        default:
            break;
        }
    }
    return nTreeFeatures;
}