First post!
[beagle.git] / Lucene.Net / Analysis / RU / RussianLowerCaseFilter.cs
blob061807f66ad1878a0783a88f9a47fc00fc81d1e4
1 using System;
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
10 * reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
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
22 * distribution.
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
51 * SUCH DAMAGE.
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/>.
60 /// <summary>
61 /// Normalizes token text to lower case, analyzing given ("russian") charset.
62 /// </summary>
63 /// <author>Boris Okner, b.okner@rogers.com</author>
64 /// <version>$Id: RussianLowerCaseFilter.cs,v 1.1.1.1 2004/04/29 22:53:51 trow Exp $</version>
65 public sealed class RussianLowerCaseFilter : TokenFilter
67 char[] charset;
69 public RussianLowerCaseFilter(TokenStream _in, char[] charset) : base(_in)
71 this.charset = charset;
74 public override Token Next()
76 Token t = input.Next();
78 if (t == null)
79 return null;
81 String txt = t.TermText();
83 char[] chArray = txt.ToCharArray();
84 for (int i = 0; i < chArray.Length; i++)
86 chArray[i] = RussianCharsets.ToLowerCase(chArray[i], charset);
89 String newTxt = new String(chArray);
90 // create new token
91 Token newToken = new Token(newTxt, t.StartOffset(), t.EndOffset());
93 return newToken;