Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
RussianStemFilter.cs
Go to the documentation of this file.
1 /*
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements. See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership. The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied. See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20 */
21 
22 using System;
23 using Lucene.Net.Analysis;
24 using Lucene.Net.Analysis.Tokenattributes;
25 
26 namespace Lucene.Net.Analysis.Ru
27 {
28  /*
29  * A {@link TokenFilter} that stems Russian words.
30  * <p>
31  * The implementation was inspired by GermanStemFilter.
32  * The input should be filtered by {@link LowerCaseFilter} before passing it to RussianStemFilter ,
33  * because RussianStemFilter only works with lowercase characters.
34  * </p>
35  */
36  public sealed class RussianStemFilter : TokenFilter
37  {
38  /*
39  * The actual token in the input stream.
40  */
41  private RussianStemmer stemmer = null;
42 
43  private ITermAttribute termAtt;
44 
46  : base(_in)
47  {
48  stemmer = new RussianStemmer();
49  termAtt = AddAttribute<ITermAttribute>();
50  }
51  /*
52  * Returns the next token in the stream, or null at EOS
53  */
54  public sealed override bool IncrementToken()
55  {
56  if (input.IncrementToken())
57  {
58  String term = termAtt.Term;
59  String s = stemmer.Stem(term);
60  if (s != null && !s.Equals(term))
61  termAtt.SetTermBuffer(s);
62  return true;
63  }
64  else
65  {
66  return false;
67  }
68  }
69 
70 
71  // I don't get the point of this. All methods in java are private, so they can't be
72  // overridden...You can't really subclass any of its behavior. I've commented it out,
73  // as it doesn't compile as is. - cc
75  // * Set a alternative/custom {@link RussianStemmer} for this filter.
76  // */
77  //public void SetStemmer(RussianStemmer stemmer)
78  //{
79  // if (stemmer != null)
80  // {
81  // this.stemmer = stemmer;
82  // }
83  //}
84  }
85 }