Example usage for edu.stanford.nlp.pipeline Annotation remove

List of usage examples for edu.stanford.nlp.pipeline Annotation remove

Introduction

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

Prototype

@Override
@SuppressWarnings("unchecked")
public <VALUE> VALUE remove(Class<? extends Key<VALUE>> key) 

Source Link

Usage

From source file:ims.cs.corenlp.PARCCoreNlpPipeline.java

License:Open Source License

/**
 * Stores CoreNlp output in a file// w  w  w  . j av a 2 s. c  o  m
 * @param a
 * @param file
 * @throws IOException
 */
public static void serializeAnnotation(Annotation a, File file) throws IOException {
    File parentFile = file.getParentFile();
    if (!parentFile.exists())
        parentFile.mkdirs();

    if (StaticConfig.verbose)
        System.out.println("(CAS) Writing to file " + file);

    // remove these to try to save memory
    a.remove(CollapsedDependenciesAnnotation.class);
    a.remove(BasicDependenciesAnnotation.class);

    if (StaticConfig.cacheParses) {
        OutputStream ret = ser.write(a, new FileOutputStream(file));
        ret.close();
    }
}