1 package org.jahia.services.search.analyzer; 2 3 56 57 import org.apache.lucene.analysis.*; 58 import java.io.Reader ; 59 import java.util.Hashtable ; 60 61 67 public class StandardAnalyzer extends Analyzer { 68 private Hashtable stopTable; 69 70 private boolean indexeAnalyzer = false; 71 72 74 public static final String [] STOP_WORDS = StopAnalyzer.ENGLISH_STOP_WORDS; 75 76 77 public StandardAnalyzer() { 78 this(false); 79 } 80 81 82 public StandardAnalyzer(boolean indexAnalyzer) { 83 this(STOP_WORDS); 84 this.indexeAnalyzer = indexAnalyzer; 85 } 86 87 88 public StandardAnalyzer(String [] stopWords) { 89 this(stopWords,false); 90 } 91 92 public StandardAnalyzer(String [] stopWords, boolean indexAnalyzer) { 93 stopTable = StopFilter.makeStopTable(stopWords); 94 this.indexeAnalyzer = indexAnalyzer; 95 } 96 97 99 public TokenStream tokenStream(String fieldName, Reader reader) { 100 TokenStream result = new StandardTokenizer(reader); 101 result = new StandardFilter(result); 102 result = new LowerCaseFilter(result); 103 result = new StopFilter(result, stopTable); 104 result = new LanguageIndependantFilter(result); 105 if ( this.indexeAnalyzer ){ 106 result = new TokenWithQuoteFilter(result); 107 } 108 return result; 109 } 110 111 112 } 113 | Popular Tags |