All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.elasticsearch.plugin.GermanPrimaryWordOnlyIndexingAnalyzerProvider Maven / Gradle / Ivy

The newest version!
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package org.elasticsearch.plugin;

import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.analysis.compound.hyphenation.HyphenationTree;
import org.apache.lucene.analysis.hunspell.Dictionary;
import org.apache.lucene.analysis.synonym.SynonymMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider;
import sirius.nlp.analyzer.de.GermanPrimaryWordExtractionAnalyzer;
import sirius.nlp.util.RessourceLoading;

/**
 * An analyzerprovider for {@link GermanPrimaryWordExtractionAnalyzer}.
 */
public class GermanPrimaryWordOnlyIndexingAnalyzerProvider
        extends AbstractIndexAnalyzerProvider {

    private GermanPrimaryWordExtractionAnalyzer analyzer;

    /**
     * Constructs a new analyzer component, with the index name and its settings and the analyzer name.
     *
     * @param indexSettings the settings and the name of the index
     * @param name          The analyzer name
     * @param environment   the environment parameter
     * @param settings      the settings
     */
    public GermanPrimaryWordOnlyIndexingAnalyzerProvider(IndexSettings indexSettings,
                                                         Environment environment,
                                                         String name,
                                                         Settings settings) {
        super(indexSettings, name, settings);

        Dictionary hunspell = RessourceLoading.getGermanHunspellDict();
        SynonymMap stemExceptionsMap = RessourceLoading.getGermanStemExceptions();
        HyphenationTree hyphenTree = RessourceLoading.getGermanHyphen();
        CharArraySet wordlistSet = RessourceLoading.getGermanWordList();

        this.analyzer =
                new GermanPrimaryWordExtractionAnalyzer(hunspell, stemExceptionsMap, hyphenTree, wordlistSet);
    }

    @Override
    public GermanPrimaryWordExtractionAnalyzer get() {
        return this.analyzer;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy