Example usage for edu.stanford.nlp.pipeline GenericAnnotationSerializer GenericAnnotationSerializer

List of usage examples for edu.stanford.nlp.pipeline GenericAnnotationSerializer GenericAnnotationSerializer

Introduction

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

Prototype

public GenericAnnotationSerializer() 

Source Link

Usage

From source file:semRewrite.substitutor.MUC.java

License:Open Source License

/** ***************************************************************
 *//*  ww  w. j ava2 s  . com*/
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);
}