Package opennlp.tools.stopword
Class StopwordLists
java.lang.Object
opennlp.tools.stopword.StopwordLists
Static factory for
StopwordFilter instances backed by bundled
language-specific stopword resources or caller-supplied input streams.
Bundled lists ship for the eleven languages enumerated in OPENNLP-660: Bulgarian (bg), Danish (da), German (de), English (en), Spanish (es), Finnish (fi), French (fr), Italian (it), Dutch (nl), Portuguese (pt), Russian (ru). Each list is keyed by its ISO 639-1 two-letter code.
-
Method Summary
Modifier and TypeMethodDescriptionstatic opennlp.tools.stopword.StopwordFilterforLanguage(String iso639Code) Returns a case-insensitiveStopwordFilterfor the given ISO 639 language code.static opennlp.tools.stopword.StopwordFilterload(InputStream in, Charset cs, boolean caseSensitive) Loads a stopword filter from a caller-supplied input stream.
-
Method Details
-
forLanguage
Returns a case-insensitiveStopwordFilterfor the given ISO 639 language code. Three-letter codes are normalized to their two-letter equivalent when a bundled list exists for the latter.- Parameters:
iso639Code- The ISO 639-1 or ISO 639-2/3 language code. Must not benull.- Returns:
- A
StopwordFilterbacked by the bundled resource. The returned instance is immutable, thread-safe and cached, so repeated calls for the same language return the same shared filter. - Throws:
IllegalArgumentException- ifiso639Codeisnull, is not a valid ISO 639 code, or has no bundled list for this language.UncheckedIOException- if reading the bundled resource fails.
-
supportedLanguages
- Returns:
- An unmodifiable view of the bundled ISO 639-1 codes for which stopword lists are shipped.
-
load
public static opennlp.tools.stopword.StopwordFilter load(InputStream in, Charset cs, boolean caseSensitive) throws IOException Loads a stopword filter from a caller-supplied input stream.- Parameters:
in- The input stream. Must not benull.cs- TheCharsetto decode with. Must not benull.caseSensitive- Whether the resulting filter matches case-sensitively.- Returns:
- A
StopwordFilterpopulated fromin. - Throws:
IllegalArgumentException- ifinorcsisnull.IOException- Thrown if an IO error occurs while reading.
-