1 package org.apache.lucene.analysis.fa;
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 static org.apache.lucene.analysis.util.StemmerUtil.*;
23 * Normalizer for Persian.
25 * Normalization is done in-place for efficiency, operating on a termbuffer.
27 * Normalization is defined as:
29 * <li>Normalization of various heh + hamza forms and heh goal to heh.
30 * <li>Normalization of farsi yeh and yeh barree to arabic yeh
31 * <li>Normalization of persian keheh to arabic kaf
35 public class PersianNormalizer {
36 public static final char YEH = '\u064A';
38 public static final char FARSI_YEH = '\u06CC';
40 public static final char YEH_BARREE = '\u06D2';
42 public static final char KEHEH = '\u06A9';
44 public static final char KAF = '\u0643';
46 public static final char HAMZA_ABOVE = '\u0654';
48 public static final char HEH_YEH = '\u06C0';
50 public static final char HEH_GOAL = '\u06C1';
52 public static final char HEH = '\u0647';
55 * Normalize an input buffer of Persian text
57 * @param s input buffer
58 * @param len length of input buffer
59 * @return length of input buffer after normalization
61 public int normalize(char s[], int len) {
63 for (int i = 0; i < len; i++) {
76 case HAMZA_ABOVE: // necessary for HEH + HAMZA
77 len = delete(s, i, len);