1 package org.apache.lucene.analysis.standard; 2 3 18 19 import org.apache.lucene.analysis.*; 20 21 import java.io.File ; 22 import java.io.IOException ; 23 import java.io.Reader ; 24 import java.util.Set ; 25 26 32 public class StandardAnalyzer extends Analyzer { 33 private Set stopSet; 34 35 37 public static final String [] STOP_WORDS = StopAnalyzer.ENGLISH_STOP_WORDS; 38 39 40 public StandardAnalyzer() { 41 this(STOP_WORDS); 42 } 43 44 45 public StandardAnalyzer(Set stopWords) { 46 stopSet = stopWords; 47 } 48 49 50 public StandardAnalyzer(String [] stopWords) { 51 stopSet = StopFilter.makeStopSet(stopWords); 52 } 53 54 57 public StandardAnalyzer(File stopwords) throws IOException { 58 stopSet = WordlistLoader.getWordSet(stopwords); 59 } 60 61 64 public StandardAnalyzer(Reader stopwords) throws IOException { 65 stopSet = WordlistLoader.getWordSet(stopwords); 66 } 67 68 70 public TokenStream tokenStream(String fieldName, Reader reader) { 71 TokenStream result = new StandardTokenizer(reader); 72 result = new StandardFilter(result); 73 result = new LowerCaseFilter(result); 74 result = new StopFilter(result, stopSet); 75 return result; 76 } 77 } 78 | Popular Tags |