1 package org.apache.lucene.analysis.gl;
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.
22 import org.apache.lucene.analysis.pt.RSLPStemmerBase;
25 * Galician stemmer implementing "Regras do lematizador para o galego".
27 * @see RSLPStemmerBase
28 * @see <a href="http://bvg.udc.es/recursos_lingua/stemming.jsp">Description of rules</a>
30 public class GalicianStemmer extends RSLPStemmerBase {
31 private static final Step plural, unification, adverb, augmentative, noun, verb, vowel;
34 Map<String,Step> steps = parse(GalicianStemmer.class, "galician.rslp");
35 plural = steps.get("Plural");
36 unification = steps.get("Unification");
37 adverb = steps.get("Adverb");
38 augmentative = steps.get("Augmentative");
39 noun = steps.get("Noun");
40 verb = steps.get("Verb");
41 vowel = steps.get("Vowel");
45 * @param s buffer, oversized to at least <code>len+1</code>
46 * @param len initial valid length of buffer
47 * @return new valid length, stemmed
49 public int stem(char s[], int len) {
50 assert s.length >= len + 1 : "this stemmer requires an oversized array of at least 1";
52 len = plural.apply(s, len);
53 len = unification.apply(s, len);
54 len = adverb.apply(s, len);
59 len = augmentative.apply(s, len);
60 } while (len != oldlen);
63 len = noun.apply(s, len);
64 if (len == oldlen) { /* suffix not removed */
65 len = verb.apply(s, len);
68 len = vowel.apply(s, len);
70 // RSLG accent removal
71 for (int i = 0; i < len; i++)
73 case 'á': s[i] = 'a'; break;
75 case 'ê': s[i] = 'e'; break;
76 case 'í': s[i] = 'i'; break;
77 case 'ó': s[i] = 'o'; break;
78 case 'ú': s[i] = 'u'; break;