Class TextCorpusStreamedWithReplaceableLayers

  • All Implemented Interfaces:
    TextCorpus, Closeable, AutoCloseable

    public class TextCorpusStreamedWithReplaceableLayers
    extends TextCorpusStored
    implements Closeable
    Class TextCorpusStreamedWithReplaceableLayers can be used for applications where an existing TCF layer has to be replaced or removed. New layers can also be added. A care should be taken by the user of this class, that there are no layers left in the TCF that depend on the layers being replaced. Do not use this class for the usual WebLicht services use case (WebLicht services are not allowed to change existing TCF layers). For the usual use case within WebLicht, use TextCorpusStreamed class.
    Author:
    Yana Panchenko
    • Constructor Detail

      • TextCorpusStreamedWithReplaceableLayers

        public TextCorpusStreamedWithReplaceableLayers​(InputStream inputStream,
                                                       EnumSet<TextCorpusLayerTag> layersToRead,
                                                       EnumSet<TextCorpusLayerTag> layersToReplace,
                                                       OutputStream outputStream)
                                                throws WLFormatException
        Creates a TextCorpusStreamedWithReplaceableLayers from the given TCF input stream,specified annotation layers and the output stream.
        Parameters:
        inputStream - the underlying input stream with linguistic annotations in TCF format.
        layersToRead - the annotation layers of TextCorpus that should be read into this TextCorpusStreamedWithReplaceableLayers.
        layersToReplace - the annotation layers of TextCorpus that should not be read into TextCorpusStreamedWithReplaceableLayers and should not be rewritten into the output stream.
        outputStream - the underlying output stream into which the annotations from the input stream and any new created annotations will be written (in TCF format).
        Throws:
        WLFormatException - if an error in input format or an I/O error occurs.
    • Method Detail

      • close

        public void close()
                   throws WLFormatException
        Closes the input and output streams associated with this object and releases any associated system resources. Before the streams are closed, all in-memory annotations of the TextCorpus and not-processed part of the input stream are written to the output stream. Therefore, it's important to call close() method, so that all the in-memory annotations are saved to the output stream. Once closed, adding further annotations will have no effect on the output stream.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Throws:
        WLFormatException - if an error in input format or an I/O error occurs.