2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace Lucene
.Net
.Analysis
22 /// <summary> Removes words that are too long and too short from the stream.
25 /// <author> David Spencer
27 /// <version> $Id: LengthFilter.cs,v 1.2 2006/10/02 17:08:47 joeshaw Exp $
29 public sealed class LengthFilter
: TokenFilter
35 /// <summary> Build a filter that removes words that are too long or too
36 /// short from the text.
38 public LengthFilter(TokenStream in_Renamed
, int min
, int max
) : base(in_Renamed
)
44 /// <summary> Returns the next input Token whose termText() is the right len</summary>
45 public override Token
Next()
47 // return the first non-stop word found
48 for (Token token
= input
.Next(); token
!= null; token
= input
.Next())
50 int len
= token
.TermText().Length
;
51 if (len
>= min
&& len
<= max
)
55 // note: else we ignore it but should we index each part of it?
57 // reached EOS -- return null