~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/analyzers/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemmer.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.apache.lucene.analysis.fr;
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
 
/* 
21
 
 * This algorithm is updated based on code located at:
22
 
 * http://members.unine.ch/jacques.savoy/clef/
23
 
 * 
24
 
 * Full copyright for that code follows:
25
 
 */
26
 
 
27
 
/*
28
 
 * Copyright (c) 2005, Jacques Savoy
29
 
 * All rights reserved.
30
 
 *
31
 
 * Redistribution and use in source and binary forms, with or without 
32
 
 * modification, are permitted provided that the following conditions are met:
33
 
 *
34
 
 * Redistributions of source code must retain the above copyright notice, this 
35
 
 * list of conditions and the following disclaimer. Redistributions in binary 
36
 
 * form must reproduce the above copyright notice, this list of conditions and
37
 
 * the following disclaimer in the documentation and/or other materials 
38
 
 * provided with the distribution. Neither the name of the author nor the names 
39
 
 * of its contributors may be used to endorse or promote products derived from 
40
 
 * this software without specific prior written permission.
41
 
 * 
42
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
43
 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
44
 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
45
 
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
46
 
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
47
 
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
48
 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
49
 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
50
 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
51
 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52
 
 * POSSIBILITY OF SUCH DAMAGE.
53
 
 */
54
 
 
55
 
/**
56
 
 * Light Stemmer for French.
57
 
 * <p>
58
 
 * This stemmer implements the following algorithm:
59
 
 * <i>A Stemming procedure and stopword list for general French corpora.</i>
60
 
 * Jacques Savoy.
61
 
 */
62
 
public class FrenchMinimalStemmer {
63
 
  public int stem(char s[], int len) {
64
 
    if (len < 6)
65
 
      return len;
66
 
    
67
 
    if (s[len-1] == 'x') {
68
 
      if (s[len-3] == 'a' && s[len-2] == 'u')
69
 
        s[len-2] = 'l';
70
 
      return len - 1;
71
 
    }
72
 
    
73
 
    if (s[len-1] == 's') len--;
74
 
    if (s[len-1] == 'r') len--;
75
 
    if (s[len-1] == 'e') len--;
76
 
    if (s[len-1] == 'é') len--;
77
 
    if (s[len-1] == s[len-2]) len--;
78
 
    return len;
79
 
  }
80
 
}