Package opennlp.tools.formats.masc

## Class MascDocumentStream

- java.lang.Object
- - opennlp.tools.formats.masc.MascDocumentStream

- All Implemented Interfaces:
    `AutoCloseable`, `ObjectStream<MascDocument>`

      public class MascDocumentStream
      extends Object
      implements ObjectStream<MascDocument>

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MascDocumentStream​(File mascCorpusDirectory)` |
    `MascDocumentStream​(File mascCorpusDirectory, boolean searchRecursive, FileFilter fileFilter)` | Creates a MascDocumentStream to read the documents from a given directory.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Remove the corpus from the memory.
    `MascDocument` | `read()` | Return the next document.
    `void` | `reset()` | Reset the reading of all documents to the first sentence.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MascDocumentStream

          public MascDocumentStream​(File mascCorpusDirectory)
                             throws IOException

      Throws:
        `IOException`

    - #### MascDocumentStream

          public MascDocumentStream​(File mascCorpusDirectory,
                                    boolean searchRecursive,
                                    FileFilter fileFilter)
                             throws IOException

      Creates a MascDocumentStream to read the documents from a given directory. Works iff all annotation files mentioned in the headers are present.
      Parameters:
        `mascCorpusDirectory` - the directory containing all the MASC files
        `searchRecursive` - whether the search should go through subdirectories
        `fileFilter` - a custom file filter to filter out some files or null to accept anything
      Throws:
        `IOException` - if any stage of the stream creation fails

  - ### Method Detail

    - #### reset

          public void reset()

      Reset the reading of all documents to the first sentence. Reset the corpus to the first document.
      Specified by:
        `reset` in interface `ObjectStream<MascDocument>`

    - #### read

          public MascDocument read()
                            throws IOException

      Return the next document. Client needs to check if this document has the necessary annotations.
      Specified by:
        `read` in interface `ObjectStream<MascDocument>`
      Returns:
        A corpus document with all its annotations.
      Throws:
        `IOException` - if anything goes wrong.

    - #### close

          public void close()

      Remove the corpus from the memory.
      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `ObjectStream<MascDocument>`