1 package org.apache.lucene.analysis.ar;
3 * Licensed to the Apache Software Foundation (ASF) under one or more
4 * contributor license agreements. See the NOTICE file distributed with
5 * this work for additional information regarding copyright ownership.
6 * The ASF licenses this file to You under the Apache License, Version 2.0
7 * (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import java.io.Reader;
21 import org.apache.lucene.analysis.CharTokenizer;
22 import org.apache.lucene.analysis.LetterTokenizer;
23 import org.apache.lucene.analysis.standard.StandardTokenizer; // javadoc @link
24 import org.apache.lucene.util.AttributeSource;
25 import org.apache.lucene.util.Version;
28 * Tokenizer that breaks text into runs of letters and diacritics.
30 * The problem with the standard Letter tokenizer is that it fails on diacritics.
31 * Handling similar to this is necessary for Indic Scripts, Hebrew, Thaana, etc.
35 * You must specify the required {@link Version} compatibility when creating
36 * {@link ArabicLetterTokenizer}:
38 * <li>As of 3.1, {@link CharTokenizer} uses an int based API to normalize and
39 * detect token characters. See {@link #isTokenChar(int)} and
40 * {@link #normalize(int)} for details.</li>
42 * @deprecated (3.1) Use {@link StandardTokenizer} instead.
45 public class ArabicLetterTokenizer extends LetterTokenizer {
49 * Construct a new ArabicLetterTokenizer.
50 * @param matchVersion Lucene version
51 * to match See {@link <a href="#version">above</a>}
54 * the input to split up into tokens
56 public ArabicLetterTokenizer(Version matchVersion, Reader in) {
57 super(matchVersion, in);
61 * Construct a new ArabicLetterTokenizer using a given {@link AttributeSource}.
64 * Lucene version to match See {@link <a href="#version">above</a>}
66 * the attribute source to use for this Tokenizer
68 * the input to split up into tokens
70 public ArabicLetterTokenizer(Version matchVersion, AttributeSource source, Reader in) {
71 super(matchVersion, source, in);
75 * Construct a new ArabicLetterTokenizer using a given
76 * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}. * @param
77 * matchVersion Lucene version to match See
78 * {@link <a href="#version">above</a>}
81 * the attribute factory to use for this Tokenizer
83 * the input to split up into tokens
85 public ArabicLetterTokenizer(Version matchVersion, AttributeFactory factory, Reader in) {
86 super(matchVersion, factory, in);
90 * Construct a new ArabicLetterTokenizer.
92 * @deprecated use {@link #ArabicLetterTokenizer(Version, Reader)} instead. This will
93 * be removed in Lucene 4.0.
96 public ArabicLetterTokenizer(Reader in) {
101 * Construct a new ArabicLetterTokenizer using a given {@link AttributeSource}.
103 * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource, Reader)}
104 * instead. This will be removed in Lucene 4.0.
107 public ArabicLetterTokenizer(AttributeSource source, Reader in) {
112 * Construct a new ArabicLetterTokenizer using a given
113 * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
115 * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource.AttributeFactory, Reader)}
116 * instead. This will be removed in Lucene 4.0.
119 public ArabicLetterTokenizer(AttributeFactory factory, Reader in) {
125 * Allows for Letter category or NonspacingMark category
126 * @see org.apache.lucene.analysis.LetterTokenizer#isTokenChar(int)
129 protected boolean isTokenChar(int c) {
130 return super.isTokenChar(c) || Character.getType(c) == Character.NON_SPACING_MARK;