2 using Lucene
.Net
.Analysis
;
4 namespace Lucene
.Net
.Analysis
.Ru
6 /* ====================================================================
7 * The Apache Software License, Version 1.1
9 * Copyright (c) 2001 The Apache Software Foundation. All rights
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in
21 * the documentation and/or other materials provided with the
24 * 3. The end-user documentation included with the redistribution,
25 * if any, must include the following acknowledgment:
26 * "This product includes software developed by the
27 * Apache Software Foundation (http://www.apache.org/)."
28 * Alternately, this acknowledgment may appear in the software itself,
29 * if and wherever such third-party acknowledgments normally appear.
31 * 4. The names "Apache" and "Apache Software Foundation" and
32 * "Apache Lucene" must not be used to endorse or promote products
33 * derived from this software without prior written permission. For
34 * written permission, please contact apache@apache.org.
36 * 5. Products derived from this software may not be called "Apache",
37 * "Apache Lucene", nor may "Apache" appear in their name, without
38 * prior written permission of the Apache Software Foundation.
40 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
44 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * ====================================================================
54 * This software consists of voluntary contributions made by many
55 * individuals on behalf of the Apache Software Foundation. For more
56 * information on the Apache Software Foundation, please see
57 * <http://www.apache.org/>.
61 /// A filter that stems Russian words. The implementation was inspired by GermanStemFilter.
62 /// The input should be filtered by RussianLowerCaseFilter before passing it to RussianStemFilter,
63 /// because RussianStemFilter only works with lowercase part of any "russian" charset.
64 /// <author>Boris Okner, b.okner@rogers.com</author>
65 /// <version>$Id: RussianStemFilter.cs,v 1.1.1.1 2004/04/29 22:53:51 trow Exp $</version>
67 public sealed class RussianStemFilter
: TokenFilter
70 /// The actual token in the input stream.
72 private Token token
= null;
73 private RussianStemmer stemmer
= null;
75 public RussianStemFilter(TokenStream _in
, char[] charset
) : base(_in
)
77 stemmer
= new RussianStemmer(charset
);
83 /// <returns>Returns the next token in the stream, or null at EOS</returns>
84 public override Token
Next()
86 if ((token
= input
.Next()) == null)
92 String s
= stemmer
.Stem(token
.TermText());
93 if (!s
.Equals(token
.TermText()))
95 return new Token(s
, token
.StartOffset(), token
.EndOffset(),
103 /// Set a alternative/custom RussianStemmer for this filter.
105 /// <param name="stemmer"></param>
106 public void SetStemmer(RussianStemmer stemmer
)
110 this.stemmer
= stemmer
;