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.
17 using Token
= Lucene
.Net
.Analysis
.Token
;
18 using TokenFilter
= Lucene
.Net
.Analysis
.TokenFilter
;
19 using TokenStream
= Lucene
.Net
.Analysis
.TokenStream
;
20 namespace Lucene
.Net
.Analysis
.RU
23 /// <summary> A filter that stems Russian words. The implementation was inspired by GermanStemFilter.
24 /// The input should be filtered by RussianLowerCaseFilter before passing it to RussianStemFilter ,
25 /// because RussianStemFilter only works with lowercase part of any "russian" charset.
28 /// <author> Boris Okner, b.okner@rogers.com
30 /// <version> $Id: RussianStemFilter.cs,v 1.2 2005/01/17 19:54:28 joeshaw Exp $
32 public sealed class RussianStemFilter
: TokenFilter
34 /// <summary> The actual token in the input stream.</summary>
35 private Token token
= null;
36 private RussianStemmer stemmer
= null;
38 public RussianStemFilter(TokenStream in_Renamed
, char[] charset
):base(in_Renamed
)
40 stemmer
= new RussianStemmer(charset
);
43 /// <returns> Returns the next token in the stream, or null at EOS
45 public override Token
Next()
47 if ((token
= input
.Next()) == null)
53 System
.String s
= stemmer
.Stem(token
.TermText());
54 if (!s
.Equals(token
.TermText()))
56 return new Token(s
, token
.StartOffset(), token
.EndOffset(), token
.Type());
62 /// <summary> Set a alternative/custom RussianStemmer for this filter.</summary>
63 public void SetStemmer(RussianStemmer stemmer
)
67 this.stemmer
= stemmer
;