You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by gs...@apache.org on 2009/03/30 19:26:55 UTC
svn commit: r760058 -
/lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java
Author: gsingers
Date: Mon Mar 30 17:26:55 2009
New Revision: 760058
URL: http://svn.apache.org/viewvc?rev=760058&view=rev
Log:
Add StopFilter makeStopSet methods that take a list, since we just call Arrays.asList() again anyway and we might already have a list
Modified:
lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java?rev=760058&r1=760057&r2=760058&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java Mon Mar 30 17:26:55 2009
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
+import java.util.List;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
@@ -110,10 +111,22 @@
public static final Set makeStopSet(String[] stopWords) {
return makeStopSet(stopWords, false);
}
+
+ /**
+ * 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 #makeStopSet(java.lang.String[], boolean) passing false to ignoreCase
+ */
+ public static final Set makeStopSet(List/*<String>*/ stopWords) {
+ return makeStopSet(stopWords, false);
+ }
/**
*
- * @param stopWords
+ * @param stopWords An array of stopwords
* @param ignoreCase If true, all words are lower cased first.
* @return a Set containing the words
*/
@@ -122,6 +135,18 @@
stopSet.addAll(Arrays.asList(stopWords));
return stopSet;
}
+
+ /**
+ *
+ * @param stopWords A List of Strings representing the stopwords
+ * @param ignoreCase if true, all words are lower cased first
+ * @return A Set containing the words
+ */
+ public static final Set makeStopSet(List/*<String>*/ stopWords, boolean ignoreCase){
+ CharArraySet stopSet = new CharArraySet(stopWords.size(), ignoreCase);
+ stopSet.addAll(stopWords);
+ return stopSet;
+ }
/**
* Returns the next input Token whose term() is not a stop word.