1 package org.apache.lucene.analysis; 2 3 18 19 import java.io.File ; 20 import java.io.IOException ; 21 import java.io.Reader ; 22 import java.util.Set ; 23 24 25 26 public final class StopAnalyzer extends Analyzer { 27 private Set stopWords; 28 29 31 public static final String [] ENGLISH_STOP_WORDS = { 32 "a", "an", "and", "are", "as", "at", "be", "but", "by", 33 "for", "if", "in", "into", "is", "it", 34 "no", "not", "of", "on", "or", "s", "such", 35 "t", "that", "the", "their", "then", "there", "these", 36 "they", "this", "to", "was", "will", "with" 37 }; 38 39 40 public StopAnalyzer() { 41 stopWords = StopFilter.makeStopSet(ENGLISH_STOP_WORDS); 42 } 43 44 46 public StopAnalyzer(Set stopWords) { 47 this.stopWords = stopWords; 48 } 49 50 51 public StopAnalyzer(String [] stopWords) { 52 this.stopWords = StopFilter.makeStopSet(stopWords); 53 } 54 55 58 public StopAnalyzer(File stopwordsFile) throws IOException { 59 stopWords = WordlistLoader.getWordSet(stopwordsFile); 60 } 61 62 65 public StopAnalyzer(Reader stopwords) throws IOException { 66 stopWords = WordlistLoader.getWordSet(stopwords); 67 } 68 69 70 public TokenStream tokenStream(String fieldName, Reader reader) { 71 return new StopFilter(new LowerCaseTokenizer(reader), stopWords); 72 } 73 } 74 75 | Popular Tags |