Example usage for org.apache.lucene.analysis.pl PolishAnalyzer DEFAULT_STEMMER_FILE

List of usage examples for org.apache.lucene.analysis.pl PolishAnalyzer DEFAULT_STEMMER_FILE

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.pl PolishAnalyzer DEFAULT_STEMMER_FILE.

Prototype

String DEFAULT_STEMMER_FILE

To view the source code for org.apache.lucene.analysis.pl PolishAnalyzer DEFAULT_STEMMER_FILE.

Click Source Link

Document

File containing default Polish stemmer table.

Usage

From source file:org.elasticsearch.index.analysis.pl.PolishStemTokenFilterFactory.java

License:Apache License

@Inject
public PolishStemTokenFilterFactory(Index index, IndexSettingsService indexSettingsService,
        @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);
    Trie tire;//from   w  ww.ja  v a 2s  . co m
    try {
        tire = StempelStemmer
                .load(PolishAnalyzer.class.getResourceAsStream(PolishAnalyzer.DEFAULT_STEMMER_FILE));
    } catch (IOException ex) {
        throw new RuntimeException("Unable to load default stemming tables", ex);
    }
    stemmer = new StempelStemmer(tire);
}

From source file:org.elasticsearch.indices.analysis.pl.PolishIndicesAnalysis.java

License:Apache License

@Inject
public PolishIndicesAnalysis(Settings settings, IndicesAnalysisService indicesAnalysisService) {
    super(settings);
    indicesAnalysisService.analyzerProviderFactories().put("polish",
            new PreBuiltAnalyzerProviderFactory("polish", AnalyzerScope.INDICES, new PolishAnalyzer()));

    indicesAnalysisService.tokenFilterFactories().put("polish_stem",
            new PreBuiltTokenFilterFactoryFactory(new TokenFilterFactory() {
                @Override/*from  ww  w  .ja  va2s.co  m*/
                public String name() {
                    return "polish_stem";
                }

                @Override
                public TokenStream create(TokenStream tokenStream) {
                    Trie tire;
                    try {
                        tire = StempelStemmer.load(
                                PolishAnalyzer.class.getResourceAsStream(PolishAnalyzer.DEFAULT_STEMMER_FILE));
                    } catch (IOException ex) {
                        throw new RuntimeException("Unable to load default stemming tables", ex);
                    }
                    return new StempelFilter(tokenStream, new StempelStemmer(tire));
                }
            }));
}