Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../img/srcFileCovDistChart5.png 77% of files have more coverage
6   74   6   1
0   33   1   6
6     1  
1    
 
  StopAnalyzer       Line # 26 6 6 50% 0.5
 
  (4)
 
1    package org.apache.lucene.analysis;
2   
3    /**
4    * Copyright 2004 The Apache Software Foundation
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing, software
13    * distributed under the License is distributed on an "AS IS" BASIS,
14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    * See the License for the specific language governing permissions and
16    * limitations under the License.
17    */
18   
19    import java.io.File;
20    import java.io.IOException;
21    import java.io.Reader;
22    import java.util.Set;
23   
24    /** Filters LetterTokenizer with LowerCaseFilter and StopFilter. */
25   
 
26    public final class StopAnalyzer extends Analyzer {
27    private Set stopWords;
28   
29    /** An array containing some common English words that are not usually useful
30    for searching. */
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", "such",
35    "that", "the", "their", "then", "there", "these",
36    "they", "this", "to", "was", "will", "with"
37    };
38   
39    /** Builds an analyzer which removes words in ENGLISH_STOP_WORDS. */
 
40  4 toggle public StopAnalyzer() {
41  4 stopWords = StopFilter.makeStopSet(ENGLISH_STOP_WORDS);
42    }
43   
44    /** Builds an analyzer with the stop words from the given set.
45    */
 
46  0 toggle public StopAnalyzer(Set stopWords) {
47  0 this.stopWords = stopWords;
48    }
49   
50    /** Builds an analyzer which removes words in the provided array. */
 
51  1 toggle public StopAnalyzer(String[] stopWords) {
52  1 this.stopWords = StopFilter.makeStopSet(stopWords);
53    }
54   
55    /** Builds an analyzer with the stop words from the given file.
56    * @see WordlistLoader#getWordSet(File)
57    */
 
58  0 toggle public StopAnalyzer(File stopwordsFile) throws IOException {
59  0 stopWords = WordlistLoader.getWordSet(stopwordsFile);
60    }
61   
62    /** Builds an analyzer with the stop words from the given reader.
63    * @see WordlistLoader#getWordSet(Reader)
64    */
 
65  0 toggle public StopAnalyzer(Reader stopwords) throws IOException {
66  0 stopWords = WordlistLoader.getWordSet(stopwords);
67    }
68   
69    /** Filters LowerCaseTokenizer with StopFilter. */
 
70  5 toggle public TokenStream tokenStream(String fieldName, Reader reader) {
71  5 return new StopFilter(new LowerCaseTokenizer(reader), stopWords);
72    }
73    }
74