Search in sources :

Example 61 with StringWriter

use of java.io.StringWriter in project CoreNLP by stanfordnlp.

the class KillAllIncomingEdges method toEditString.

@Override
public String toEditString() {
    StringWriter buf = new StringWriter();
    buf.write(LABEL);
    buf.write("\t");
    buf.write(Ssurgeon.NODENAME_ARG);
    buf.write("\t");
    buf.write(nodeName);
    return buf.toString();
}
Also used : StringWriter(java.io.StringWriter)

Example 62 with StringWriter

use of java.io.StringWriter in project CoreNLP by stanfordnlp.

the class RemoveEdge method toEditString.

@Override
public String toEditString() {
    StringWriter buf = new StringWriter();
    buf.write(LABEL);
    buf.write("\t");
    buf.write(Ssurgeon.RELN_ARG);
    buf.write(" ");
    buf.write(relation.toString());
    buf.write("\t");
    buf.write(Ssurgeon.GOV_NODENAME_ARG);
    buf.write(" ");
    buf.write(govName);
    buf.write("\t");
    buf.write(Ssurgeon.DEP_NODENAME_ARG);
    buf.write(" ");
    buf.write(depName);
    return buf.toString();
}
Also used : StringWriter(java.io.StringWriter)

Example 63 with StringWriter

use of java.io.StringWriter in project CoreNLP by stanfordnlp.

the class RVFDataset method toSummaryString.

public String toSummaryString() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("Number of data points: " + size());
    pw.print("Number of labels: " + labelIndex.size() + " [");
    Iterator<L> iter = labelIndex.iterator();
    while (iter.hasNext()) {
        pw.print(iter.next());
        if (iter.hasNext()) {
            pw.print(", ");
        }
    }
    pw.println("]");
    pw.println("Number of features (Phi(X) types): " + featureIndex.size());
    pw.println("Number of active feature types: " + numFeatureTypes());
    pw.println("Number of active feature tokens: " + numFeatureTokens());
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 64 with StringWriter

use of java.io.StringWriter in project CoreNLP by stanfordnlp.

the class ResultsPrinter method printResults.

public String printResults(List<String> goldStandard, List<String> extractorOutput) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    printResultsUsingLabels(pw, goldStandard, extractorOutput);
    return sw.getBuffer().toString();
}
Also used : StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter)

Example 65 with StringWriter

use of java.io.StringWriter in project CoreNLP by stanfordnlp.

the class ResultsPrinter method printResults.

/**
   * Given a set of sentences with annotations from an information extractor class, and the same sentences
   * with gold-standard annotations, print results on how the information extraction performed.
   */
public String printResults(CoreMap goldStandard, CoreMap extractorOutput) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw, true);
    List<CoreMap> mutableGold = new ArrayList<>();
    mutableGold.addAll(goldStandard.get(CoreAnnotations.SentencesAnnotation.class));
    List<CoreMap> mutableOutput = new ArrayList<>();
    mutableOutput.addAll(extractorOutput.get(CoreAnnotations.SentencesAnnotation.class));
    printResults(pw, mutableGold, mutableOutput);
    return sw.getBuffer().toString();
}
Also used : StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) CoreMap(edu.stanford.nlp.util.CoreMap) PrintWriter(java.io.PrintWriter)

Aggregations

StringWriter (java.io.StringWriter)3563 PrintWriter (java.io.PrintWriter)1197 Test (org.junit.Test)686 IOException (java.io.IOException)563 StringReader (java.io.StringReader)258 Writer (java.io.Writer)239 StreamResult (javax.xml.transform.stream.StreamResult)239 File (java.io.File)207 HashMap (java.util.HashMap)154 Transformer (javax.xml.transform.Transformer)154 InputStreamReader (java.io.InputStreamReader)152 InputStream (java.io.InputStream)137 Map (java.util.Map)125 ArrayList (java.util.ArrayList)122 DOMSource (javax.xml.transform.dom.DOMSource)122 BufferedReader (java.io.BufferedReader)106 ByteArrayInputStream (java.io.ByteArrayInputStream)99 Reader (java.io.Reader)85 Marshaller (javax.xml.bind.Marshaller)82 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)81