/** * Wrapper around xmlPrint(Annotation, OutputStream). * Added for backward compatibility. * * @param annotation The Annotation to print * @param w The Writer to send the output to * @throws IOException If any IO problem */ public void xmlPrint(Annotation annotation, Writer w) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); xmlPrint(annotation, os); // this builds it as the encoding specified in the properties w.write(new String(os.toByteArray(), getEncoding())); w.flush(); }
public void outputXml(PrintWriter out, Annotation annotation) throws IOException { outputByWriter(writer -> { try { pipeline.xmlPrint(annotation, writer); } catch (IOException e) { throw new RuntimeIOException(e); } }, out); }
pipeline.xmlPrint(annotation, xmlOutput); xmlOutput.flush();
pipeline.xmlPrint(annotation, xmlOut);
pipeline.prettyPrint(annotation, out); if (xmlOut != null) { pipeline.xmlPrint(annotation, xmlOut);
/** * Wrapper around xmlPrint(Annotation, OutputStream). * Added for backward compatibility. * @param annotation * @param w The Writer to send the output to * @throws IOException */ public void xmlPrint(Annotation annotation, Writer w) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); xmlPrint(annotation, os); // this builds it as UTF-8, always w.write(new String(os.toByteArray(), "UTF-8")); // This will convert it to something else w.flush(); }
/** * Wrapper around xmlPrint(Annotation, OutputStream). * Added for backward compatibility. * @param annotation * @param w The Writer to send the output to * @throws IOException */ public void xmlPrint(Annotation annotation, Writer w) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); xmlPrint(annotation, os); // this builds it as the encoding specified in the properties w.write(new String(os.toByteArray(), getEncoding())); w.flush(); }
/** * Wrapper around xmlPrint(Annotation, OutputStream). * Added for backward compatibility. * * @param annotation The Annotation to print * @param w The Writer to send the output to * @throws IOException If any IO problem */ public void xmlPrint(Annotation annotation, Writer w) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); xmlPrint(annotation, os); // this builds it as the encoding specified in the properties w.write(new String(os.toByteArray(), getEncoding())); w.flush(); }
Properties props = new Properties(); props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); Annotation document = new Annotation("Four score and seven years ago."); pipeline.annotate(document); FileOutputStream os = new FileOutputStream(new File("./target/", "nlp.xml")); pipeline.xmlPrint(document, os);
xmlPrint(annotation, writer); writer.close(); } else if (outputFormat.equalsIgnoreCase("text")) {
switch (outputFormat) { case XML: pipeline.xmlPrint(anno, System.out); break; case TEXT:
"This is a short sentence. And this is another."); pipeline.annotate(annotation); pipeline.xmlPrint(annotation, xmlOut);
pipeline.prettyPrint(annotation, out); if (xmlOut != null) { pipeline.xmlPrint(annotation, xmlOut);
case XML: { OutputStream fos = new BufferedOutputStream(new FileOutputStream(finalOutputFilename)); xmlPrint(annotation, fos); fos.close(); break;