pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / analyzers / common / src / java / org / apache / lucene / analysis / ar / ArabicLetterTokenizer.java
1 package org.apache.lucene.analysis.ar;
2 /**
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
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 import java.io.Reader;
20
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;
26
27 /**
28  * Tokenizer that breaks text into runs of letters and diacritics.
29  * <p>
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.
32  * </p>
33  * <p>
34  * <a name="version"/>
35  * You must specify the required {@link Version} compatibility when creating
36  * {@link ArabicLetterTokenizer}:
37  * <ul>
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>
41  * </ul>
42  * @deprecated (3.1) Use {@link StandardTokenizer} instead.
43  */
44 @Deprecated
45 public class ArabicLetterTokenizer extends LetterTokenizer {
46
47   
48   /**
49    * Construct a new ArabicLetterTokenizer.
50    * @param matchVersion Lucene version
51    * to match See {@link <a href="#version">above</a>}
52    * 
53    * @param in
54    *          the input to split up into tokens
55    */
56   public ArabicLetterTokenizer(Version matchVersion, Reader in) {
57     super(matchVersion, in);
58   }
59
60   /**
61    * Construct a new ArabicLetterTokenizer using a given {@link AttributeSource}.
62    * 
63    * @param matchVersion
64    *          Lucene version to match See {@link <a href="#version">above</a>}
65    * @param source
66    *          the attribute source to use for this Tokenizer
67    * @param in
68    *          the input to split up into tokens
69    */
70   public ArabicLetterTokenizer(Version matchVersion, AttributeSource source, Reader in) {
71     super(matchVersion, source, in);
72   }
73
74   /**
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>}
79    * 
80    * @param factory
81    *          the attribute factory to use for this Tokenizer
82    * @param in
83    *          the input to split up into tokens
84    */
85   public ArabicLetterTokenizer(Version matchVersion, AttributeFactory factory, Reader in) {
86     super(matchVersion, factory, in);
87   }
88   
89   /**
90    * Construct a new ArabicLetterTokenizer.
91    * 
92    * @deprecated use {@link #ArabicLetterTokenizer(Version, Reader)} instead. This will
93    *             be removed in Lucene 4.0.
94    */
95   @Deprecated
96   public ArabicLetterTokenizer(Reader in) {
97     super(in);
98   }
99
100   /**
101    * Construct a new ArabicLetterTokenizer using a given {@link AttributeSource}.
102    * 
103    * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource, Reader)}
104    *             instead. This will be removed in Lucene 4.0.
105    */
106   @Deprecated
107   public ArabicLetterTokenizer(AttributeSource source, Reader in) {
108     super(source, in);
109   }
110
111   /**
112    * Construct a new ArabicLetterTokenizer using a given
113    * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
114    * 
115    * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource.AttributeFactory, Reader)}
116    *             instead. This will be removed in Lucene 4.0.
117    */
118   @Deprecated
119   public ArabicLetterTokenizer(AttributeFactory factory, Reader in) {
120     super(factory, in);
121   }
122   
123   
124   /** 
125    * Allows for Letter category or NonspacingMark category
126    * @see org.apache.lucene.analysis.LetterTokenizer#isTokenChar(int)
127    */
128   @Override
129   protected boolean isTokenChar(int c) {
130     return super.isTokenChar(c) || Character.getType(c) == Character.NON_SPACING_MARK;
131   }
132
133 }