Class ConlluDependencySampleStream

java.lang.Object
opennlp.tools.formats.conllu.ConlluDependencySampleStream
All Implemented Interfaces:
AutoCloseable, opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample>

public class ConlluDependencySampleStream extends Object implements opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample>
Reads samples directly from CoNLL-U content, mapping the HEAD and DEPREL columns of the basic dependency annotation.

This reader does not use ConlluStream, which merges multiword token ranges with their syntactic words for token and lemma samples. Dependency samples instead omit range lines and empty nodes while retaining the syntactic word rows. Sentences with incomplete or invalid basic dependencies are skipped and counted.

Since:
3.0.0
  • Constructor Details

    • ConlluDependencySampleStream

      public ConlluDependencySampleStream(opennlp.tools.util.InputStreamFactory in, ConlluTagset tagset) throws IOException
      Initializes the stream.
      Parameters:
      in - The CoNLL-U content. Must not be null.
      tagset - The tagset whose part-of-speech column feeds the sample tags. Must not be null.
      Throws:
      IOException - Thrown if opening the content fails.
      IllegalArgumentException - Thrown if any parameter is null.
  • Method Details

    • read

      public opennlp.tools.depparse.DependencySample read() throws IOException

      Sentences without a usable basic dependency annotation are skipped, and their count is logged once the content is exhausted.

      Specified by:
      read in interface opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample>
      Throws:
      IOException
    • reset

      public void reset() throws IOException, UnsupportedOperationException

      Reopens the content through the InputStreamFactory, which must therefore produce a fresh stream on every call.

      Specified by:
      reset in interface opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample>
      Throws:
      IOException
      UnsupportedOperationException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface opennlp.tools.util.ObjectStream<opennlp.tools.depparse.DependencySample>
      Throws:
      IOException