Support for Latvian stemming: `latvian` analyzer and `latvian` language for stemmer filter, closes #1842.
This commit is contained in:
parent
9cd51ce177
commit
30ffaca3ee
|
@ -498,6 +498,7 @@ public class AnalysisModule extends AbstractModule {
|
|||
analyzersBindings.processAnalyzer("hungarian", HungarianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("indonesian", IndonesianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("italian", ItalianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("latvian", LatvianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("norwegian", NorwegianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("persian", PersianAnalyzerProvider.class);
|
||||
analyzersBindings.processAnalyzer("portuguese", PortugueseAnalyzerProvider.class);
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.index.analysis;
|
||||
|
||||
import org.apache.lucene.analysis.CharArraySet;
|
||||
import org.apache.lucene.analysis.lv.LatvianAnalyzer;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.inject.assistedinject.Assisted;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.settings.IndexSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class LatvianAnalyzerProvider extends AbstractIndexAnalyzerProvider<LatvianAnalyzer> {
|
||||
|
||||
private final LatvianAnalyzer analyzer;
|
||||
|
||||
@Inject
|
||||
public LatvianAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) {
|
||||
super(index, indexSettings, name, settings);
|
||||
analyzer = new LatvianAnalyzer(version,
|
||||
Analysis.parseStopWords(env, settings, LatvianAnalyzer.getDefaultStopSet(), version),
|
||||
Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatvianAnalyzer get() {
|
||||
return this.analyzer;
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ import org.apache.lucene.analysis.hi.HindiStemFilter;
|
|||
import org.apache.lucene.analysis.hu.HungarianLightStemFilter;
|
||||
import org.apache.lucene.analysis.id.IndonesianStemFilter;
|
||||
import org.apache.lucene.analysis.it.ItalianLightStemFilter;
|
||||
import org.apache.lucene.analysis.lv.LatvianStemFilter;
|
||||
import org.apache.lucene.analysis.pt.PortugueseLightStemFilter;
|
||||
import org.apache.lucene.analysis.pt.PortugueseMinimalStemFilter;
|
||||
import org.apache.lucene.analysis.pt.PortugueseStemFilter;
|
||||
|
@ -102,6 +103,8 @@ public class StemmerTokenFilterFactory extends AbstractTokenFilterFactory {
|
|||
return new KStemFilter(tokenStream);
|
||||
} else if ("lovins".equalsIgnoreCase(language)) {
|
||||
return new SnowballFilter(tokenStream, new LovinsStemmer());
|
||||
} else if ("latvian".equalsIgnoreCase(language)) {
|
||||
return new LatvianStemFilter(tokenStream);
|
||||
} else if ("norwegian".equalsIgnoreCase(language)) {
|
||||
return new SnowballFilter(tokenStream, new NorwegianStemmer());
|
||||
} else if ("porter".equalsIgnoreCase(language)) {
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.apache.lucene.analysis.hu.HungarianAnalyzer;
|
|||
import org.apache.lucene.analysis.hy.ArmenianAnalyzer;
|
||||
import org.apache.lucene.analysis.id.IndonesianAnalyzer;
|
||||
import org.apache.lucene.analysis.it.ItalianAnalyzer;
|
||||
import org.apache.lucene.analysis.lv.LatvianAnalyzer;
|
||||
import org.apache.lucene.analysis.miscellaneous.*;
|
||||
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
|
||||
import org.apache.lucene.analysis.ngram.EdgeNGramTokenizer;
|
||||
|
@ -141,6 +142,7 @@ public class IndicesAnalysisService extends AbstractComponent {
|
|||
analyzerProviderFactories.put("hungarian", new PreBuiltAnalyzerProviderFactory("hungarian", AnalyzerScope.INDICES, new HungarianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("indonesian", new PreBuiltAnalyzerProviderFactory("indonesian", AnalyzerScope.INDICES, new IndonesianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("italian", new PreBuiltAnalyzerProviderFactory("italian", AnalyzerScope.INDICES, new ItalianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("latvian", new PreBuiltAnalyzerProviderFactory("latvian", AnalyzerScope.INDICES, new LatvianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("norwegian", new PreBuiltAnalyzerProviderFactory("norwegian", AnalyzerScope.INDICES, new NorwegianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("persian", new PreBuiltAnalyzerProviderFactory("persian", AnalyzerScope.INDICES, new PersianAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
analyzerProviderFactories.put("portuguese", new PreBuiltAnalyzerProviderFactory("portuguese", AnalyzerScope.INDICES, new PortugueseAnalyzer(Lucene.ANALYZER_VERSION)));
|
||||
|
|
Loading…
Reference in New Issue