public static String objectToJSON(Consumer<Writer> callback) { OutputStream os = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(os); new JSONWriter(out, new Options()).object(callback); out.close(); return os.toString(); } }
StanfordCoreNLP.createOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false); StanfordCoreNLP.createOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false);
/** * Like the {@link Document@xml(Function...)} function, but with minified XML more suitable * for sending over the wire. * * @param functions The (possibly empty) list of annotations to populate on the document before dumping it * to XML. * @return The XML String for this document, without unecessary whitespace. * */ @SafeVarargs public final String xmlMinified(Function<Sentence, Object>... functions) { for (Function<Sentence, Object> f : functions) { f.apply(this.sentence(0)); } try { AnnotationOutputter.Options options = new AnnotationOutputter.Options(false); return new XMLOutputter().print(this.asAnnotation(false), options); } catch (IOException e) { throw new RuntimeIOException(e); } }
StanfordCoreNLP.createOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false); StanfordCoreNLP.createOutputter(properties, new AnnotationOutputter.Options()), outputFormat, false);
/** * Like the {@link Document@xml(Function...)} function, but with minified XML more suitable * for sending over the wire. * * @param functions The (possibly empty) list of annotations to populate on the document before dumping it * to XML. * @return The XML String for this document, without unecessary whitespace. * */ @SafeVarargs public final String xmlMinified(Function<Sentence, Object>... functions) { for (Function<Sentence, Object> f : functions) { f.apply(this.sentence(0)); } try { AnnotationOutputter.Options options = new AnnotationOutputter.Options(false); return new XMLOutputter().print(this.asAnnotation(false), options); } catch (IOException e) { throw new RuntimeIOException(e); } }
/** * Like the {@link Document@json(Function...)} function, but with minified JSON more suitable * for sending over the wire. * * @param functions The (possibly empty) list of annotations to populate on the document before dumping it * to JSON. * @return The JSON String for this document, without unnecessary whitespace. * */ @SafeVarargs public final String jsonMinified(Function<Sentence, Object>... functions) { for (Function<Sentence, Object> f : functions) { f.apply(this.sentence(0)); } try { AnnotationOutputter.Options options = new AnnotationOutputter.Options(false); return new JSONOutputter().print(this.asAnnotation(), options); } catch (IOException e) { throw new RuntimeIOException(e); } }
public static String objectToJSON(Consumer<Writer> callback) { OutputStream os = new ByteArrayOutputStream(); PrintWriter out = new PrintWriter(os); new JSONWriter(out, new Options()).object(callback); out.close(); return os.toString(); } }
/** * Populates options from StanfordCoreNLP pipeline. */ public static Options getOptions(Properties properties) { return new Options(properties); }
/** * Like the {@link Document@json(Function...)} function, but with minified JSON more suitable * for sending over the wire. * * @param functions The (possibly empty) list of annotations to populate on the document before dumping it * to JSON. * @return The JSON String for this document, without unnecessary whitespace. * */ @SafeVarargs public final String jsonMinified(Function<Sentence, Object>... functions) { for (Function<Sentence, Object> f : functions) { f.apply(this.sentence(0)); } try { AnnotationOutputter.Options options = new AnnotationOutputter.Options(false); return new JSONOutputter().print(this.asAnnotation(), options); } catch (IOException e) { throw new RuntimeIOException(e); } }
/** * Populates options from StanfordCoreNLP pipeline. */ public static Options getOptions(Properties properties) { return new Options(properties); }