public CzechAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, name, settings); analyzer = new CzechAnalyzer( Analysis.parseStopWords(env, indexSettings.getIndexVersionCreated(), settings, CzechAnalyzer.getDefaultStopSet()), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET) ); analyzer.setVersion(version); }
@Inject public CzechAnalyzerProvider(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettingsService.getSettings(), name, settings); analyzer = new CzechAnalyzer(Analysis.parseStopWords(env, settings, CzechAnalyzer.getDefaultStopSet()), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET)); analyzer.setVersion(version); }
/** * Ritorna il set di stop words di default per una lingua * * @param language lingua * @return set di stop words */ public static CharArraySet getDefaultStopSet(String language) { try { if ("en".equalsIgnoreCase(language)) { return StandardAnalyzer.STOP_WORDS_SET; } else if ("es".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "spanish_stop.txt", StandardCharsets.UTF_8)); } else if ("fr".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "french_stop.txt", StandardCharsets.UTF_8)); } else if ("de".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "german_stop.txt", StandardCharsets.UTF_8)); } else if ("pl".equalsIgnoreCase(language)) { return WordlistLoader.getWordSet(IOUtils.getDecodingReader(PolishAnalyzer.class, "stopwords.txt", StandardCharsets.UTF_8), "#"); } else if ("pt".equalsIgnoreCase(language) || "br".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "portuguese_stop.txt", StandardCharsets.UTF_8)); } else if ("it".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "italian_stop.txt", StandardCharsets.UTF_8)); } else if ("cz".equalsIgnoreCase(language) || "sk".equalsIgnoreCase(language)) { return WordlistLoader.getWordSet(IOUtils.getDecodingReader(CzechAnalyzer.class, "stopwords.txt", StandardCharsets.UTF_8), "#"); } else if ("tr".equalsIgnoreCase(language)) { return TurkishAnalyzer.loadStopwordSet(false, TurkishAnalyzer.class, "stopwords.txt", "#"); } else if ("ru".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "russian_stop.txt", StandardCharsets.UTF_8)); } else if ("ro".equalsIgnoreCase(language)) { return RomanianAnalyzer.loadStopwordSet(false, RomanianAnalyzer.class, "stopwords.txt", "#"); } else if ("bg".equalsIgnoreCase(language)) { return BulgarianAnalyzer.loadStopwordSet(false, BulgarianAnalyzer.class, "stopwords.txt", "#"); } else if ("nl".equalsIgnoreCase(language)) { return WordlistLoader.getSnowballWordSet(IOUtils.getDecodingReader(SnowballFilter.class, "dutch_stop.txt", StandardCharsets.UTF_8)); } } catch (Exception ignored) { throw new RuntimeException("Unable to load default stopword set"); } return StandardAnalyzer.STOP_WORDS_SET; }
@Override public CzechAnalyzer get() { return this.analyzer; }