Search in sources :

Example 6 with StringOutputStream

use of edu.stanford.nlp.io.StringOutputStream in project CoreNLP by stanfordnlp.

the class CharniakScoredParsesReaderWriter method parsesToString.

/**
   * Convert list of scored parse trees to string representing scored parses
   *   (in the charniak parser output format)
   * @param parses - list of scored parse trees
   * @return string representing scored parses
   */
public String parsesToString(List<ScoredObject<Tree>> parses) {
    if (parses == null)
        return null;
    StringOutputStream os = new StringOutputStream();
    PrintWriter pw = new PrintWriter(os);
    printScoredTrees(pw, 0, parses);
    pw.close();
    return os.toString();
}
Also used : StringOutputStream(edu.stanford.nlp.io.StringOutputStream) PrintWriter(java.io.PrintWriter)

Aggregations

StringOutputStream (edu.stanford.nlp.io.StringOutputStream)6 PrintWriter (java.io.PrintWriter)3 DecimalFormat (java.text.DecimalFormat)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2