/** * Converts parse tree to string in Penn Treebank format. * * Implementation note: Internally, the method gains * efficiency by chaining use of a single {@code StringBuilder} * through all the printing. * * @return the tree as a bracketed list on one line */ @Override public String toString() { return toStringBuilder(new StringBuilder(Tree.initialPrintStringBuilderSize)).toString(); }
private static String printTree(Tree tree) { StringBuilder sb = new StringBuilder(); return tree.toStringBuilder(sb).toString(); }
/** * Appends the printed form of a parse tree (as a bracketed String) * to a {@code StringBuilder}. * The implementation of this may be more efficient than for * {@code toString()} on complex trees. * * @param sb The {@code StringBuilder} to which the tree will be appended * @return Returns the {@code StringBuilder} passed in with extra stuff in it */ public StringBuilder toStringBuilder(StringBuilder sb) { return toStringBuilder(sb, label -> (label.value() == null) ? "": label.value()); }
for (Tree kid : kids) { sb.append(' '); kid.toStringBuilder(sb, labelFormatter);
String terminalString = toStringBuilder(new StringBuilder(), labelFormatter).toString(); pw.print(terminalString); pw.flush();
/** * Appends the printed form of a parse tree (as a bracketed String) * to a {@code StringBuilder}. * The implementation of this may be more efficient than for * {@code toString()} on complex trees. * * @param sb The {@code StringBuilder} to which the tree will be appended * @return Returns the {@code StringBuilder} passed in with extra stuff in it */ public StringBuilder toStringBuilder(StringBuilder sb) { return toStringBuilder(sb, true); }
/** * Appends the printed form of a parse tree (as a bracketed String) * to an <code>Appendable</code>, such as a <code>StringBuffer</code>. * The implementation of this may be more efficient than for * <code>toString()</code> on complex trees. * * @param sb The <code>StringBuilder</code> to which the tree will be appended * @return Returns the <code>StringBuilder</code> passed in with extra stuff in it */ public StringBuilder toStringBuilder(StringBuilder sb) { return toStringBuilder(sb, true); }
/** * Converts parse tree to string in Penn Treebank format. * <p> * Implementation note: Internally, the method gains * efficiency by chaining use of a single <code>StringBuilder</code> * through all the printing. * * @return the tree as a bracketed list on one line */ @Override public String toString() { return toStringBuilder(new StringBuilder(Tree.initialPrintStringBuilderSize)).toString(); }
/** * Converts parse tree to string in Penn Treebank format. * <p> * Implementation note: Internally, the method gains * efficiency by chaining use of a single <code>StringBuilder</code> * through all the printing. * * @return the tree as a bracketed list on one line */ @Override public String toString() { return toStringBuilder(new StringBuilder(Tree.initialPrintStringBuilderSize)).toString(); }
private static String printTree(Tree tree) { StringBuilder sb = new StringBuilder(); return tree.toStringBuilder(sb, true).toString(); }
private static String printTree(Tree tree) { StringBuilder sb = new StringBuilder(); return tree.toStringBuilder(sb).toString(); }
private static String printTree(Tree tree) { StringBuilder sb = new StringBuilder(); return tree.toStringBuilder(sb, true).toString(); }
/** * Converts parse tree to string in Penn Treebank format. * * Implementation note: Internally, the method gains * efficiency by chaining use of a single {@code StringBuilder} * through all the printing. * * @return the tree as a bracketed list on one line */ @Override public String toString() { return toStringBuilder(new StringBuilder(Tree.initialPrintStringBuilderSize)).toString(); }
/** * Converts parse tree to string in Penn Treebank format. * * Implementation note: Internally, the method gains * efficiency by chaining use of a single {@code StringBuilder} * through all the printing. * * @return the tree as a bracketed list on one line */ @Override public String toString() { return toStringBuilder(new StringBuilder(Tree.initialPrintStringBuilderSize)).toString(); }
/** * Appends the printed form of a parse tree (as a bracketed String) * to a {@code StringBuilder}. * The implementation of this may be more efficient than for * {@code toString()} on complex trees. * * @param sb The {@code StringBuilder} to which the tree will be appended * @return Returns the {@code StringBuilder} passed in with extra stuff in it */ public StringBuilder toStringBuilder(StringBuilder sb) { return toStringBuilder(sb, label -> (label.value() == null) ? "": label.value()); }
/** * Appends the printed form of a parse tree (as a bracketed String) * to a {@code StringBuilder}. * The implementation of this may be more efficient than for * {@code toString()} on complex trees. * * @param sb The {@code StringBuilder} to which the tree will be appended * @return Returns the {@code StringBuilder} passed in with extra stuff in it */ public StringBuilder toStringBuilder(StringBuilder sb) { return toStringBuilder(sb, label -> (label.value() == null) ? "": label.value()); }
for (Tree kid : kids) { sb.append(' '); kid.toStringBuilder(sb, labelFormatter);
for (Tree kid : kids) { sb.append(' '); kid.toStringBuilder(sb, labelFormatter);
String terminalString = toStringBuilder(new StringBuilder(), labelFormatter).toString(); pw.print(terminalString); pw.flush();
String terminalString = toStringBuilder(new StringBuilder(), labelFormatter).toString(); pw.print(terminalString); pw.flush();