lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gsing...@apache.org
Subject svn commit: r760058 - /lucene/java/trunk/src/java/org/apache/lucene/analysis/StopFilter.java
Date Mon, 30 Mar 2009 17:26:55 GMT
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.



Mime
View raw message