Package opennlp.tools.stopword

# Class DictionaryStopwordFilter.Builder

java.lang.Object
opennlp.tools.stopword.DictionaryStopwordFilter.Builder

Enclosing class:
  `DictionaryStopwordFilter`

public static final class DictionaryStopwordFilter.Builder extends Object
Fluent builder for `DictionaryStopwordFilter`. Accumulates `add` / `remove` operations together with a case-sensitivity setting; `build()` produces an immutable filter that reflects the accumulated state.

Operations are applied at `build()` time in the order "all adds, then all removes". Within each phase, insertion order is preserved but is not externally observable.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DictionaryStopwordFilter.Builder`
  `add(String... tokens)`
  Adds one entry (1-gram or n-gram).
  `DictionaryStopwordFilter.Builder`
  `addAll(Collection<String[]> entries)`
  Adds a bulk of entries.
  `DictionaryStopwordFilter`
  `build()`
  `DictionaryStopwordFilter.Builder`
  `caseSensitive(boolean cs)`
  `DictionaryStopwordFilter.Builder`
  `load(InputStream in, Charset cs)`
  Reads one-per-line stopword entries from `in` (whitespace separates tokens of a multi-word entry; blank and `#`-prefixed lines are skipped) and schedules them for addition.
  `DictionaryStopwordFilter.Builder`
  `remove(String... tokens)`
  Schedules removal of one entry (applied after all adds at `build()` time).
  `DictionaryStopwordFilter.Builder`
  `removeAll(Collection<String[]> entries)`
  Schedules a bulk of removals.

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

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

- ## Method Details

  - ### caseSensitive

    public DictionaryStopwordFilter.Builder caseSensitive(boolean cs)
    Parameters:
      `cs` - Whether the resulting filter performs case-sensitive matching. Defaults to `false`.
    Returns:
      This builder.

  - ### add

    public DictionaryStopwordFilter.Builder add(String... tokens)
    Adds one entry (1-gram or n-gram).
    Parameters:
      `tokens` - The tokens forming the entry. Must not be `null` or empty.
    Returns:
      This builder.
    Throws:
      `IllegalArgumentException` - if `tokens` is `null` or empty.

  - ### addAll

    public DictionaryStopwordFilter.Builder addAll(Collection<String[]> entries)
    Adds a bulk of entries.
    Parameters:
      `entries` - The entries to add. Must not be `null`.
    Returns:
      This builder.
    Throws:
      `IllegalArgumentException` - if `entries` is `null`, or if any element is `null` or empty.

  - ### remove

    public DictionaryStopwordFilter.Builder remove(String... tokens)
    Schedules removal of one entry (applied after all adds at `build()` time).
    Parameters:
      `tokens` - The tokens forming the entry to remove.
    Returns:
      This builder.
    Throws:
      `IllegalArgumentException` - if `tokens` is `null` or empty.

  - ### removeAll

    public DictionaryStopwordFilter.Builder removeAll(Collection<String[]> entries)
    Schedules a bulk of removals.
    Parameters:
      `entries` - The entries to remove. Must not be `null`.
    Returns:
      This builder.
    Throws:
      `IllegalArgumentException` - if `entries` is `null`, or if any element is `null` or empty.

  - ### load

    public DictionaryStopwordFilter.Builder load(InputStream in, Charset cs) throws IOException
    Reads one-per-line stopword entries from `in` (whitespace separates tokens of a multi-word entry; blank and `#`-prefixed lines are skipped) and schedules them for addition.
    Parameters:
      `in` - The input stream to read from. Must not be `null`.
      `cs` - The `Charset` to decode with. Must not be `null`.
    Returns:
      This builder.
    Throws:
      `IllegalArgumentException` - if `in` or `cs` is `null`.
      `IOException` - If an IO error occurs while reading.

  - ### build

    public DictionaryStopwordFilter build()
    Returns:
      A new immutable `DictionaryStopwordFilter` reflecting the accumulated state.