org.apache.lucene.analysis
Class StopFilter
- java.lang.Object
-
- org.apache.lucene.analysis.TokenStream
-
- org.apache.lucene.analysis.TokenFilter
-
- org.apache.lucene.analysis.StopFilter
-
public final class StopFilter extends TokenFilter
Removes stop words from a token stream.
-
-
Constructor Summary
Constructors Constructor and Description StopFilter(TokenStream in, java.util.Set stopWords)Constructs a filter which removes words from the input TokenStream that are named in the Set.StopFilter(TokenStream input, java.util.Set stopWords, boolean ignoreCase)Construct a token stream filtering the given input.StopFilter(TokenStream input, java.lang.String[] stopWords)Construct a token stream filtering the given input.StopFilter(TokenStream in, java.lang.String[] stopWords, boolean ignoreCase)Constructs a filter which removes words from the input TokenStream that are named in the array of words.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleangetEnablePositionIncrements()static booleangetEnablePositionIncrementsDefault()static java.util.SetmakeStopSet(java.lang.String[] stopWords)Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor.static java.util.SetmakeStopSet(java.lang.String[] stopWords, boolean ignoreCase)Tokennext(Token result)Returns the next input Token whose termText() is not a stop word.voidsetEnablePositionIncrements(boolean enable)Set totrueto make this StopFilter enable position increments to result tokens.static voidsetEnablePositionIncrementsDefault(boolean defaultValue)Set the default position increments behavior of every StopFilter created from now on.-
Methods inherited from class org.apache.lucene.analysis.TokenFilter
close
-
Methods inherited from class org.apache.lucene.analysis.TokenStream
next, reset
-
-
-
-
Constructor Detail
-
StopFilter
public StopFilter(TokenStream input, java.lang.String[] stopWords)
Construct a token stream filtering the given input.
-
StopFilter
public StopFilter(TokenStream in, java.lang.String[] stopWords, boolean ignoreCase)
Constructs a filter which removes words from the input TokenStream that are named in the array of words.
-
StopFilter
public StopFilter(TokenStream input, java.util.Set stopWords, boolean ignoreCase)
Construct a token stream filtering the given input. IfstopWordsis an instance ofCharArraySet(true ifmakeStopSet()was used to construct the set) it will be directly used andignoreCasewill be ignored sinceCharArraySetdirectly controls case sensitivity. IfstopWordsis not an instance ofCharArraySet, a new CharArraySet will be constructed andignoreCasewill be used to specify the case sensitivity of that set.- Parameters:
input-stopWords- The set of Stop Words.ignoreCase- -Ignore case when stopping.
-
StopFilter
public StopFilter(TokenStream in, java.util.Set stopWords)
Constructs a filter which removes words from the input TokenStream that are named in the Set.- See Also:
makeStopSet(java.lang.String[])
-
-
Method Detail
-
makeStopSet
public static final java.util.Set makeStopSet(java.lang.String[] stopWords)
Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor. This permits this stopWords construction to be cached once when an Analyzer is constructed.- See Also:
passing false to ignoreCase
-
makeStopSet
public static final java.util.Set makeStopSet(java.lang.String[] stopWords, boolean ignoreCase)- Parameters:
stopWords-ignoreCase- If true, all words are lower cased first.- Returns:
- a Set containing the words
-
next
public final Token next(Token result) throws java.io.IOException
Returns the next input Token whose termText() is not a stop word.- Overrides:
nextin classTokenStream- Parameters:
result- a Token that may or may not be used to return- Returns:
- next token in the stream or null if end-of-stream was hit
- Throws:
java.io.IOException
-
getEnablePositionIncrementsDefault
public static boolean getEnablePositionIncrementsDefault()
-
setEnablePositionIncrementsDefault
public static void setEnablePositionIncrementsDefault(boolean defaultValue)
Set the default position increments behavior of every StopFilter created from now on.Note: behavior of a single StopFilter instance can be modified with
setEnablePositionIncrements(boolean). This static method allows control over behavior of classes using StopFilters internally, for exampleStandardAnalyzer.Default : false.
- See Also:
setEnablePositionIncrements(boolean).
-
getEnablePositionIncrements
public boolean getEnablePositionIncrements()
- See Also:
setEnablePositionIncrements(boolean).
-
setEnablePositionIncrements
public void setEnablePositionIncrements(boolean enable)
Set totrueto make this StopFilter enable position increments to result tokens.When set, when a token is stopped (omitted), the position increment of the following token is incremented.
Default: see
setEnablePositionIncrementsDefault(boolean).
-
-
DataMelt 3.0 © DataMelt by jWork.ORG