Example usage for edu.stanford.nlp.pipeline AnnotationSerializer read

List of usage examples for edu.stanford.nlp.pipeline AnnotationSerializer read

Introduction

In this page you can find the example usage for edu.stanford.nlp.pipeline AnnotationSerializer read.

Prototype

public abstract Pair<Annotation, InputStream> read(InputStream is)
        throws IOException, ClassNotFoundException, ClassCastException;

Source Link

Document

Read a single object from this stream.

Usage

From source file:semRewrite.substitutor.MUC.java

License:Open Source License

/** ***************************************************************
 *///from   ww w . java 2  s .c om
public static void testSerialize() {

    String input = "The cat is on the mat.";
    AnnotationSerializer as = new GenericAnnotationSerializer();
    Properties props = new Properties();
    props.setProperty("annotators", "tokenize, ....");
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
    Annotation document1 = new Annotation(input);
    pipeline.annotate(document1);
    OutputStream os = new OutputStream() {
        @Override
        public void write(int b) throws IOException {

        }
    };
    try {
        as.write(document1, os);
    } catch (Exception e) {

    }

    InputStream is = new InputStream() {
        @Override
        public int read() throws IOException {
            return 0;
        }
    };
    Pair p = null;
    try {
        p = as.read(is);
    } catch (Exception e) {

    }
    document1 = (Annotation) p.first();
    List<CoreMap> sentences = document1.get(CoreAnnotations.SentencesAnnotation.class);
}