Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Analysis / RU / RussianStemFilter.cs
blobf3c534749e236d4bb7254ce2e996dd51d2d79f7c
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
16 using System;
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.
26 ///
27 /// </summary>
28 /// <author> Boris Okner, b.okner@rogers.com
29 /// </author>
30 /// <version> $Id: RussianStemFilter.cs,v 1.2 2005/01/17 19:54:28 joeshaw Exp $
31 /// </version>
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
44 /// </returns>
45 public override Token Next()
47 if ((token = input.Next()) == null)
49 return null;
51 else
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());
58 return token;
62 /// <summary> Set a alternative/custom RussianStemmer for this filter.</summary>
63 public void SetStemmer(RussianStemmer stemmer)
65 if (stemmer != null)
67 this.stemmer = stemmer;