mirror of https://github.com/apache/lucene.git
another refinement to the ongoing StopFilter refactorings
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150227 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3c93b62676
commit
8d7ce21934
|
@ -65,7 +65,7 @@ import java.util.Set;
|
|||
|
||||
public final class StopFilter extends TokenFilter {
|
||||
|
||||
private Set table;
|
||||
private Set stopWords;
|
||||
|
||||
/**
|
||||
* Constructs a filter which removes words from the input
|
||||
|
@ -73,7 +73,7 @@ public final class StopFilter extends TokenFilter {
|
|||
*/
|
||||
public StopFilter(TokenStream in, String[] stopWords) {
|
||||
super(in);
|
||||
table = makeStopSet(stopWords);
|
||||
this.stopWords = makeStopSet(stopWords);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,16 +84,16 @@ public final class StopFilter extends TokenFilter {
|
|||
*/
|
||||
public StopFilter(TokenStream in, Hashtable stopTable) {
|
||||
super(in);
|
||||
table = stopTable.keySet();
|
||||
stopWords = new HashSet(stopTable.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a filter which removes words from the input
|
||||
* TokenStream that are named in the Set.
|
||||
*/
|
||||
public StopFilter(TokenStream in, Set stopTable) {
|
||||
public StopFilter(TokenStream in, Set stopWords) {
|
||||
super(in);
|
||||
table = stopTable;
|
||||
this.stopWords = new HashSet(stopWords);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ public final class StopFilter extends TokenFilter {
|
|||
/**
|
||||
* Builds a Set from an array of stop words,
|
||||
* appropriate for passing into the StopFilter constructor.
|
||||
* This permits this table construction to be cached once when
|
||||
* This permits this stopWords construction to be cached once when
|
||||
* an Analyzer is constructed.
|
||||
*/
|
||||
public static final Set makeStopSet(String[] stopWords) {
|
||||
|
@ -130,7 +130,7 @@ public final class StopFilter extends TokenFilter {
|
|||
public final Token next() throws IOException {
|
||||
// return the first non-stop word found
|
||||
for (Token token = input.next(); token != null; token = input.next())
|
||||
if (!table.contains(token.termText))
|
||||
if (!stopWords.contains(token.termText))
|
||||
return token;
|
||||
// reached EOS -- return null
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue