1 package org.apache.lucene.analysis.ar;
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 import java.io.IOException;
21 import java.io.StringReader;
23 import org.apache.lucene.analysis.BaseTokenStreamTestCase;
26 * Test the Arabic Normalization Filter
28 public class TestArabicNormalizationFilter extends BaseTokenStreamTestCase {
30 public void testAlifMadda() throws IOException {
34 public void testAlifHamzaAbove() throws IOException {
35 check("أحمد", "احمد");
38 public void testAlifHamzaBelow() throws IOException {
39 check("إعاذ", "اعاذ");
42 public void testAlifMaksura() throws IOException {
46 public void testTehMarbuta() throws IOException {
47 check("فاطمة", "فاطمه");
50 public void testTatweel() throws IOException {
51 check("روبرـــــت", "روبرت");
54 public void testFatha() throws IOException {
55 check("مَبنا", "مبنا");
58 public void testKasra() throws IOException {
62 public void testDamma() throws IOException {
63 check("بُوات", "بوات");
66 public void testFathatan() throws IOException {
67 check("ولداً", "ولدا");
70 public void testKasratan() throws IOException {
74 public void testDammatan() throws IOException {
78 public void testSukun() throws IOException {
79 check("نلْسون", "نلسون");
82 public void testShaddah() throws IOException {
83 check("هتميّ", "هتمي");
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});