Package opennlp.tools.stopword
Class StopwordFilterStream
java.lang.Object
opennlp.tools.util.FilterObjectStream<String[],String[]>
opennlp.tools.stopword.StopwordFilterStream
- All Implemented Interfaces:
AutoCloseable,opennlp.tools.util.ObjectStream<String[]>
A
FilterObjectStream which removes stopwords from each
String[] sample produced by an underlying
ObjectStream<String[]>.
Stopword membership is decided by the supplied StopwordFilter;
filtering is delegated to StopwordFilter.filter(String[]) so the
relative order of surviving tokens within a sample is preserved.
FilterObjectStream.reset() and FilterObjectStream.close() are inherited from
FilterObjectStream and simply forward to the wrapped stream.
-
Constructor Summary
ConstructorsConstructorDescriptionStopwordFilterStream(opennlp.tools.util.ObjectStream<String[]> samples, opennlp.tools.stopword.StopwordFilter filter) Initializes aStopwordFilterStream. -
Method Summary
Methods inherited from class opennlp.tools.util.FilterObjectStream
close, reset
-
Constructor Details
-
StopwordFilterStream
public StopwordFilterStream(opennlp.tools.util.ObjectStream<String[]> samples, opennlp.tools.stopword.StopwordFilter filter) Initializes aStopwordFilterStream.- Parameters:
samples- TheObjectStreamof token arrays to filter. Must not benull.filter- TheStopwordFilterused to drop stopwords. Must not benull.- Throws:
IllegalArgumentException- ifsamplesorfilterisnull.
-
-
Method Details
-
read
Reads the next sample from the wrapped stream and returns it with stopwords removed. Returnsnullonce the underlying stream is exhausted.- Returns:
- The filtered sample or
nullat the end of the stream. - Throws:
IOException- If the underlying stream throws an I/O error.
-