mirror of https://github.com/apache/lucene.git
convenience constructors that load list of stop words from a file
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@168970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c3f90ad76e
commit
9f78244f9e
|
@ -16,6 +16,8 @@ package org.apache.lucene.analysis;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -43,6 +45,11 @@ public final class StopAnalyzer extends Analyzer {
|
|||
public StopAnalyzer(String[] stopWords) {
|
||||
this.stopWords = StopFilter.makeStopSet(stopWords);
|
||||
}
|
||||
|
||||
/** Builds an analyzer with the stop words from the given file. */
|
||||
public StopAnalyzer(File stopwordsFile) throws IOException {
|
||||
stopWords = WordlistLoader.getWordSet(stopwordsFile);
|
||||
}
|
||||
|
||||
/** Filters LowerCaseTokenizer with StopFilter. */
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
|
|
|
@ -17,6 +17,9 @@ package org.apache.lucene.analysis.standard;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.analysis.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -43,6 +46,11 @@ public class StandardAnalyzer extends Analyzer {
|
|||
stopSet = StopFilter.makeStopSet(stopWords);
|
||||
}
|
||||
|
||||
/** Builds an analyzer with the stop words from the given file. */
|
||||
public StandardAnalyzer(File stopwords) throws IOException {
|
||||
stopSet = WordlistLoader.getWordSet(stopwords);
|
||||
}
|
||||
|
||||
/** Constructs a {@link StandardTokenizer} filtered by a {@link
|
||||
StandardFilter}, a {@link LowerCaseFilter} and a {@link StopFilter}. */
|
||||
public TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
|
|
Loading…
Reference in New Issue