opennlp.tools.postag
Class WordTagSampleStream

java.lang.Object
  extended by opennlp.tools.util.FilterObjectStream<String,POSSample>
      extended by opennlp.tools.postag.WordTagSampleStream
All Implemented Interfaces:
ObjectStream<POSSample>

public class WordTagSampleStream
extends FilterObjectStream<String,POSSample>

A stream filter which reads a sentence per line which contains words and tags in word_tag format and outputs a POSSample objects.


Field Summary
 
Fields inherited from class opennlp.tools.util.FilterObjectStream
samples
 
Constructor Summary
WordTagSampleStream(ObjectStream<String> sentences)
           
WordTagSampleStream(Reader sentences)
          Initializes the current instance.
 
Method Summary
 POSSample read()
          Parses the next sentence and return the next POSSample object.
 
Methods inherited from class opennlp.tools.util.FilterObjectStream
close, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordTagSampleStream

public WordTagSampleStream(Reader sentences)
                    throws IOException
Initializes the current instance.

Parameters:
sentences -
Throws:
IOException

WordTagSampleStream

public WordTagSampleStream(ObjectStream<String> sentences)
Method Detail

read

public POSSample read()
               throws IOException
Parses the next sentence and return the next POSSample object. If an error occurs an empty POSSample object is returned and an warning message is logged. Usually it does not matter if one of many sentences is ignored. TODO: An exception in error case should be thrown.

Returns:
the next object or null to signal that the stream is exhausted
Throws:
IOException


Copyright © 2010. All Rights Reserved.