add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / analyzers / common / src / test / org / apache / lucene / analysis / ar / TestArabicNormalizationFilter.java
1 package org.apache.lucene.analysis.ar;
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.IOException;
21 import java.io.StringReader;
22
23 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
24
25 /**
26  * Test the Arabic Normalization Filter
27  */
28 public class TestArabicNormalizationFilter extends BaseTokenStreamTestCase {
29
30   public void testAlifMadda() throws IOException {
31     check("آجن", "اجن");
32   }
33   
34   public void testAlifHamzaAbove() throws IOException {
35     check("أحمد", "احمد");
36   }
37   
38   public void testAlifHamzaBelow() throws IOException {
39     check("إعاذ", "اعاذ");
40   }
41   
42   public void testAlifMaksura() throws IOException {
43     check("بنى", "بني");
44   }
45
46   public void testTehMarbuta() throws IOException {
47     check("فاطمة", "فاطمه");
48   }
49   
50   public void testTatweel() throws IOException {
51     check("روبرـــــت", "روبرت");
52   }
53   
54   public void testFatha() throws IOException {
55     check("مَبنا", "مبنا");
56   }
57   
58   public void testKasra() throws IOException {
59     check("علِي", "علي");
60   }
61   
62   public void testDamma() throws IOException {
63     check("بُوات", "بوات");
64   }
65   
66   public void testFathatan() throws IOException {
67     check("ولداً", "ولدا");
68   }
69   
70   public void testKasratan() throws IOException {
71     check("ولدٍ", "ولد");
72   }
73   
74   public void testDammatan() throws IOException {
75     check("ولدٌ", "ولد");
76   }  
77   
78   public void testSukun() throws IOException {
79     check("نلْسون", "نلسون");
80   }
81   
82   public void testShaddah() throws IOException {
83     check("هتميّ", "هتمي");
84   }  
85   
86   private void check(final String input, final String expected) throws IOException {
87     ArabicLetterTokenizer tokenStream = new ArabicLetterTokenizer(TEST_VERSION_CURRENT, new StringReader(input));
88     ArabicNormalizationFilter filter = new ArabicNormalizationFilter(tokenStream);
89     assertTokenStreamContents(filter, new String[]{expected});
90   }
91
92 }