Clover Coverage Report
Coverage timestamp: Fri May 9 2008 10:54:27 EST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
16   68   9   8
10   34   0.56   2
2     4.5  
1    
 
  StandardFilter       Line # 23 16 9 100% 1.0
 
  (29)
 
1    package org.apache.lucene.analysis.standard;
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 org.apache.lucene.analysis.*;
20   
21    /** Normalizes tokens extracted with {@link StandardTokenizer}. */
22   
 
23    public final class StandardFilter extends TokenFilter
24    implements StandardTokenizerConstants {
25   
26   
27    /** Construct filtering <i>in</i>. */
 
28  6517 toggle public StandardFilter(TokenStream in) {
29  6517 super(in);
30    }
31   
32    private static final String APOSTROPHE_TYPE = tokenImage[APOSTROPHE];
33    private static final String ACRONYM_TYPE = tokenImage[ACRONYM];
34   
35    /** Returns the next token in the stream, or null at EOS.
36    * <p>Removes <tt>'s</tt> from the end of words.
37    * <p>Removes dots from acronyms.
38    */
 
39  13674 toggle public final org.apache.lucene.analysis.Token next() throws java.io.IOException {
40  13674 org.apache.lucene.analysis.Token t = input.next();
41   
42  13674 if (t == null)
43  6517 return null;
44   
45  7157 String text = t.termText();
46  7157 String type = t.type();
47   
48  7157 if (type == APOSTROPHE_TYPE && // remove 's
49    (text.endsWith("'s") || text.endsWith("'S"))) {
50  3 return new org.apache.lucene.analysis.Token
51    (text.substring(0,text.length()-2),
52    t.startOffset(), t.endOffset(), type);
53   
54  7154 } else if (type == ACRONYM_TYPE) { // remove dots
55  1 StringBuffer trimmed = new StringBuffer();
56  7 for (int i = 0; i < text.length(); i++) {
57  6 char c = text.charAt(i);
58  6 if (c != '.')
59  3 trimmed.append(c);
60    }
61  1 return new org.apache.lucene.analysis.Token
62    (trimmed.toString(), t.startOffset(), t.endOffset(), type);
63   
64    } else {
65  7153 return t;
66    }
67    }
68    }