org.apache.lucene.analysis

## Class StopwordAnalyzerBase

- java.lang.Object
- - org.apache.lucene.analysis.Analyzer
  - - org.apache.lucene.analysis.StopwordAnalyzerBase

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Direct Known Subclasses:
    StandardAnalyzer

      public abstract class StopwordAnalyzerBase
      extends Analyzer

  Base class for Analyzers that need to make use of stopword sets.
  Since:
    3.1

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer

      `Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CharArraySet` | `stopwords` An immutable stopword set

    - ### Fields inherited from class org.apache.lucene.analysis.Analyzer

      `GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `StopwordAnalyzerBase()` Creates a new Analyzer with an empty stopword set
    `protected` | `StopwordAnalyzerBase(CharArraySet stopwords)` Creates a new instance initialized with the given stopword set

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CharArraySet` | `getStopwordSet()` Returns the analyzer's stopword set or an empty set if the analyzer has no stopwords
    `protected static CharArraySet` | `loadStopwordSet(boolean ignoreCase, Class<? extends Analyzer> aClass, String resource, String comment)` Creates a CharArraySet from a file resource associated with a class.
    `protected static CharArraySet` | `loadStopwordSet(Path stopwords)` Creates a CharArraySet from a path.
    `protected static CharArraySet` | `loadStopwordSet(Reader stopwords)` Creates a CharArraySet from a file.

    - ### Methods inherited from class org.apache.lucene.analysis.Analyzer

      `attributeFactory, close, createComponents, getOffsetGap, getPositionIncrementGap, getReuseStrategy, getVersion, initReader, initReaderForNormalization, normalize, normalize, setVersion, tokenStream, tokenStream`

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

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

- - ### Field Detail

    - #### stopwords

          protected final CharArraySet stopwords

      An immutable stopword set

  - ### Constructor Detail

    - #### StopwordAnalyzerBase

          protected StopwordAnalyzerBase(CharArraySet stopwords)

      Creates a new instance initialized with the given stopword set
      Parameters:
        `stopwords` - the analyzer's stopword set

    - #### StopwordAnalyzerBase

          protected StopwordAnalyzerBase()

      Creates a new Analyzer with an empty stopword set

  - ### Method Detail

    - #### getStopwordSet

          public CharArraySet getStopwordSet()

      Returns the analyzer's stopword set or an empty set if the analyzer has no stopwords
      Returns:
        the analyzer's stopword set or an empty set if the analyzer has no stopwords

    - #### loadStopwordSet

          protected static CharArraySet loadStopwordSet(boolean ignoreCase,
                                                        Class<? extends Analyzer> aClass,
                                                        String resource,
                                                        String comment)
                                                 throws IOException

      Creates a CharArraySet from a file resource associated with a class. (See `Class.getResourceAsStream(String)`).
      Parameters:
        `ignoreCase` - `true` if the set should ignore the case of the stopwords, otherwise `false`
        `aClass` - a class that is associated with the given stopwordResource
        `resource` - name of the resource file associated with the given class
        `comment` - comment string to ignore in the stopword file
      Returns:
        a CharArraySet containing the distinct stopwords from the given file
      Throws:
        `IOException` - if loading the stopwords throws an `IOException`

    - #### loadStopwordSet

          protected static CharArraySet loadStopwordSet(Path stopwords)
                                                 throws IOException

      Creates a CharArraySet from a path.
      Parameters:
        `stopwords` - the stopwords file to load
      Returns:
        a CharArraySet containing the distinct stopwords from the given file
      Throws:
        `IOException` - if loading the stopwords throws an `IOException`

    - #### loadStopwordSet

          protected static CharArraySet loadStopwordSet(Reader stopwords)
                                                 throws IOException

      Creates a CharArraySet from a file.
      Parameters:
        `stopwords` - the stopwords reader to load
      Returns:
        a CharArraySet containing the distinct stopwords from the given reader
      Throws:
        `IOException` - if loading the stopwords throws an `IOException`

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.