1 package org.apache.lucene.analysis.ru;
2
3 /**
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * 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, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20 import java.io.Reader;
21 import org.apache.lucene.analysis.CharTokenizer;
22 import org.apache.lucene.analysis.Tokenizer; // for javadocs
23 import org.apache.lucene.analysis.LetterTokenizer; // for javadocs
24 import org.apache.lucene.util.AttributeSource;
25
26 /**
27 * A RussianLetterTokenizer is a {@link Tokenizer} that extends {@link LetterTokenizer}
28 * by also allowing the basic latin digits 0-9.
29 */
30
31 public class RussianLetterTokenizer extends CharTokenizer
32 {
33 public RussianLetterTokenizer(Reader in)
34 {
35 super(in);
36 }
37
38 public RussianLetterTokenizer(AttributeSource source, Reader in)
39 {
40 super(source, in);
41 }
42
43 public RussianLetterTokenizer(AttributeFactory factory, Reader in)
44 {
45 super(factory, in);
46 }
47
48 /**
49 * Collects only characters which satisfy
50 * {@link Character#isLetter(char)}.
51 */
52 @Override
53 protected boolean isTokenChar(char c)
54 {
55 if (Character.isLetter(c) || (c >= '0' && c <= '9'))
56 return true;
57 else
58 return false;
59 }
60 }