Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Analysis / RU / RussianLetterTokenizer.cs
blob19517d151ec1cc9995b1519dac300182dd08d107
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 CharTokenizer = Lucene.Net.Analysis.CharTokenizer;
18 namespace Lucene.Net.Analysis.RU
21 /// <summary> A RussianLetterTokenizer is a tokenizer that extends LetterTokenizer by additionally looking up letters
22 /// in a given "russian charset". The problem with LeterTokenizer is that it uses Character.isLetter() method,
23 /// which doesn't know how to detect letters in encodings like CP1252 and KOI8
24 /// (well-known problems with 0xD7 and 0xF7 chars)
25 ///
26 /// </summary>
27 /// <author> Boris Okner, b.okner@rogers.com
28 /// </author>
29 /// <version> $Id: RussianLetterTokenizer.cs,v 1.2 2005/01/17 19:54:28 joeshaw Exp $
30 /// </version>
32 public class RussianLetterTokenizer : CharTokenizer
34 /// <summary>Construct a new LetterTokenizer. </summary>
35 private char[] charset;
37 public RussianLetterTokenizer(System.IO.TextReader in_Renamed, char[] charset) : base(in_Renamed)
39 this.charset = charset;
42 /// <summary> Collects only characters which satisfy
43 /// {@link Character#isLetter(char)}.
44 /// </summary>
45 protected internal override bool IsTokenChar(char c)
47 if (System.Char.IsLetter(c))
48 return true;
49 for (int i = 0; i < charset.Length; i++)
51 if (c == charset[i])
52 return true;
54 return false;