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

« back to all changes in this revision

Viewing changes to lucene/contrib/analyzers/common/src/test/org/apache/lucene/analysis/fr/TestFrenchLightStemFilter.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
 
import java.io.IOException;
21
 
import java.io.Reader;
22
 
 
23
 
import org.apache.lucene.analysis.Analyzer;
24
 
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
25
 
import org.apache.lucene.analysis.MockTokenizer;
26
 
import org.apache.lucene.analysis.Tokenizer;
27
 
import org.apache.lucene.analysis.ReusableAnalyzerBase;
28
 
 
29
 
import static org.apache.lucene.analysis.VocabularyAssert.*;
30
 
 
31
 
/**
32
 
 * Simple tests for {@link FrenchLightStemFilter}
33
 
 */
34
 
public class TestFrenchLightStemFilter extends BaseTokenStreamTestCase {
35
 
  private Analyzer analyzer = new ReusableAnalyzerBase() {
36
 
    @Override
37
 
    protected TokenStreamComponents createComponents(String fieldName,
38
 
        Reader reader) {
39
 
      Tokenizer source = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
40
 
      return new TokenStreamComponents(source, new FrenchLightStemFilter(source));
41
 
    }
42
 
  };
43
 
  
44
 
  /** Test some examples from the paper */
45
 
  public void testExamples() throws IOException {
46
 
    checkOneTerm(analyzer, "chevaux", "cheval");
47
 
    checkOneTerm(analyzer, "cheval", "cheval");
48
 
    
49
 
    checkOneTerm(analyzer, "hiboux", "hibou");
50
 
    checkOneTerm(analyzer, "hibou", "hibou");
51
 
    
52
 
    checkOneTerm(analyzer, "chantés", "chant");
53
 
    checkOneTerm(analyzer, "chanter", "chant");
54
 
    checkOneTerm(analyzer, "chante", "chant");
55
 
    checkOneTerm(analyzer, "chant", "chant");
56
 
    
57
 
    checkOneTerm(analyzer, "baronnes", "baron");
58
 
    checkOneTerm(analyzer, "barons", "baron");
59
 
    checkOneTerm(analyzer, "baron", "baron");
60
 
    
61
 
    checkOneTerm(analyzer, "peaux", "peau");
62
 
    checkOneTerm(analyzer, "peau", "peau");
63
 
    
64
 
    checkOneTerm(analyzer, "anneaux", "aneau");
65
 
    checkOneTerm(analyzer, "anneau", "aneau");
66
 
    
67
 
    checkOneTerm(analyzer, "neveux", "neveu");
68
 
    checkOneTerm(analyzer, "neveu", "neveu");
69
 
    
70
 
    checkOneTerm(analyzer, "affreux", "afreu");
71
 
    checkOneTerm(analyzer, "affreuse", "afreu");
72
 
    
73
 
    checkOneTerm(analyzer, "investissement", "investi");
74
 
    checkOneTerm(analyzer, "investir", "investi");
75
 
    
76
 
    checkOneTerm(analyzer, "assourdissant", "asourdi");
77
 
    checkOneTerm(analyzer, "assourdir", "asourdi");
78
 
    
79
 
    checkOneTerm(analyzer, "pratiquement", "pratiqu");
80
 
    checkOneTerm(analyzer, "pratique", "pratiqu");
81
 
    
82
 
    checkOneTerm(analyzer, "administrativement", "administratif");
83
 
    checkOneTerm(analyzer, "administratif", "administratif");
84
 
    
85
 
    checkOneTerm(analyzer, "justificatrice", "justifi");
86
 
    checkOneTerm(analyzer, "justificateur", "justifi");
87
 
    checkOneTerm(analyzer, "justifier", "justifi");
88
 
    
89
 
    checkOneTerm(analyzer, "educatrice", "eduqu");
90
 
    checkOneTerm(analyzer, "eduquer", "eduqu");
91
 
    
92
 
    checkOneTerm(analyzer, "communicateur", "comuniqu");
93
 
    checkOneTerm(analyzer, "communiquer", "comuniqu");
94
 
    
95
 
    checkOneTerm(analyzer, "accompagnatrice", "acompagn");
96
 
    checkOneTerm(analyzer, "accompagnateur", "acompagn");
97
 
    
98
 
    checkOneTerm(analyzer, "administrateur", "administr");
99
 
    checkOneTerm(analyzer, "administrer", "administr");
100
 
    
101
 
    checkOneTerm(analyzer, "productrice", "product");
102
 
    checkOneTerm(analyzer, "producteur", "product");
103
 
    
104
 
    checkOneTerm(analyzer, "acheteuse", "achet");
105
 
    checkOneTerm(analyzer, "acheteur", "achet");
106
 
    
107
 
    checkOneTerm(analyzer, "planteur", "plant");
108
 
    checkOneTerm(analyzer, "plante", "plant");
109
 
    
110
 
    checkOneTerm(analyzer, "poreuse", "poreu");
111
 
    checkOneTerm(analyzer, "poreux", "poreu");
112
 
    
113
 
    checkOneTerm(analyzer, "plieuse", "plieu");
114
 
    
115
 
    checkOneTerm(analyzer, "bijoutière", "bijouti");
116
 
    checkOneTerm(analyzer, "bijoutier", "bijouti");
117
 
    
118
 
    checkOneTerm(analyzer, "caissière", "caisi");
119
 
    checkOneTerm(analyzer, "caissier", "caisi");
120
 
    
121
 
    checkOneTerm(analyzer, "abrasive", "abrasif");
122
 
    checkOneTerm(analyzer, "abrasif", "abrasif");
123
 
    
124
 
    checkOneTerm(analyzer, "folle", "fou");
125
 
    checkOneTerm(analyzer, "fou", "fou");
126
 
    
127
 
    checkOneTerm(analyzer, "personnelle", "person");
128
 
    checkOneTerm(analyzer, "personne", "person");
129
 
    
130
 
    // algo bug: too short length
131
 
    //checkOneTerm(analyzer, "personnel", "person");
132
 
    
133
 
    checkOneTerm(analyzer, "complète", "complet");
134
 
    checkOneTerm(analyzer, "complet", "complet");
135
 
    
136
 
    checkOneTerm(analyzer, "aromatique", "aromat");
137
 
    
138
 
    checkOneTerm(analyzer, "faiblesse", "faibl");
139
 
    checkOneTerm(analyzer, "faible", "faibl");
140
 
    
141
 
    checkOneTerm(analyzer, "patinage", "patin");
142
 
    checkOneTerm(analyzer, "patin", "patin");
143
 
    
144
 
    checkOneTerm(analyzer, "sonorisation", "sono");
145
 
    
146
 
    checkOneTerm(analyzer, "ritualisation", "rituel");
147
 
    checkOneTerm(analyzer, "rituel", "rituel");
148
 
    
149
 
    // algo bug: masked by rules above
150
 
    //checkOneTerm(analyzer, "colonisateur", "colon");
151
 
    
152
 
    checkOneTerm(analyzer, "nomination", "nomin");
153
 
    
154
 
    checkOneTerm(analyzer, "disposition", "dispos");
155
 
    checkOneTerm(analyzer, "dispose", "dispos");
156
 
  }
157
 
  
158
 
  /** Test against a vocabulary from the reference impl */
159
 
  public void testVocabulary() throws IOException {
160
 
    assertVocabulary(analyzer, getDataFile("frlighttestdata.zip"), "frlight.txt");
161
 
  }
162
 
  
163
 
  /** blast some random strings through the analyzer */
164
 
  public void testRandomStrings() throws Exception {
165
 
    checkRandomData(random, analyzer, 10000*RANDOM_MULTIPLIER);
166
 
  }
167
 
}