List of usage examples for org.apache.lucene.analysis.sv SwedishAnalyzer getDefaultStopSet
public static CharArraySet getDefaultStopSet()
From source file:com.stratio.cassandra.lucene.schema.analysis.SnowballAnalyzerBuilder.java
License:Apache License
/** * Returns the default stopwords set used by Lucene language analyzer for the specified language. * * @param language The language for which the stopwords are. The supported languages are English, French, Spanish, * Portuguese, Italian, Romanian, German, Dutch, Swedish, Norwegian, Danish, Russian, Finnish, * Irish, Hungarian, Turkish, Armenian, Basque and Catalan. * @return The default stopwords set used by Lucene language analyzers. *//*from ww w . java2 s .c o m*/ private static CharArraySet getDefaultStopwords(String language) { switch (language) { case "English": return EnglishAnalyzer.getDefaultStopSet(); case "French": return FrenchAnalyzer.getDefaultStopSet(); case "Spanish": return SpanishAnalyzer.getDefaultStopSet(); case "Portuguese": return PortugueseAnalyzer.getDefaultStopSet(); case "Italian": return ItalianAnalyzer.getDefaultStopSet(); case "Romanian": return RomanianAnalyzer.getDefaultStopSet(); case "German": return GermanAnalyzer.getDefaultStopSet(); case "Dutch": return DutchAnalyzer.getDefaultStopSet(); case "Swedish": return SwedishAnalyzer.getDefaultStopSet(); case "Norwegian": return NorwegianAnalyzer.getDefaultStopSet(); case "Danish": return DanishAnalyzer.getDefaultStopSet(); case "Russian": return RussianAnalyzer.getDefaultStopSet(); case "Finnish": return FinnishAnalyzer.getDefaultStopSet(); case "Irish": return IrishAnalyzer.getDefaultStopSet(); case "Hungarian": return HungarianAnalyzer.getDefaultStopSet(); case "Turkish": return SpanishAnalyzer.getDefaultStopSet(); case "Armenian": return SpanishAnalyzer.getDefaultStopSet(); case "Basque": return BasqueAnalyzer.getDefaultStopSet(); case "Catalan": return CatalanAnalyzer.getDefaultStopSet(); default: return CharArraySet.EMPTY_SET; } }
From source file:com.stratio.cassandra.lucene.schema.analysis.StandardStopwordsTest.java
License:Apache License
@Test public void testGetSwedishPreBuiltAnalyzer() { CharArraySet stopwords = StandardStopwords.SWEDISH.get(); assertEquals("Expected another stopwords", SwedishAnalyzer.getDefaultStopSet(), stopwords); }
From source file:it.unipd.dei.ims.lucene.clef.AnalyzerFactory.java
License:Apache License
public static CharArraySet createStopset(String language, String stopsetType, String stopsetPath) throws Exception { CharArraySet stopset = CharArraySet.EMPTY_SET; if (stopsetType.equalsIgnoreCase("CUSTOM")) { try {/* ww w. j a v a 2 s.c om*/ File f = new File(stopsetPath); stopset = new CharArraySet(0, true); Scanner sc = new Scanner(f); logger.debug("STOPLIST:"); while (sc.hasNextLine()) { String stopword = sc.nextLine().trim(); logger.debug("=> " + stopword); stopset.add(stopword); } logger.debug(""); sc.close(); } catch (FileNotFoundException e) { e.printStackTrace(); throw new Exception("FileNotFoundException when loading stopset"); } } else if (stopsetType.equalsIgnoreCase("DEFAULT")) { switch (language) { case "bg": stopset = BulgarianAnalyzer.getDefaultStopSet(); break; case "de": stopset = GermanAnalyzer.getDefaultStopSet(); break; case "es": stopset = SpanishAnalyzer.getDefaultStopSet(); break; case "fa": stopset = PersianAnalyzer.getDefaultStopSet(); break; case "fi": stopset = FinnishAnalyzer.getDefaultStopSet(); break; case "fr": stopset = FrenchAnalyzer.getDefaultStopSet(); break; case "hu": stopset = HungarianAnalyzer.getDefaultStopSet(); break; case "it": stopset = ItalianAnalyzer.getDefaultStopSet(); break; case "nl": stopset = DutchAnalyzer.getDefaultStopSet(); break; case "pt": stopset = PortugueseAnalyzer.getDefaultStopSet(); break; case "ru": stopset = RussianAnalyzer.getDefaultStopSet(); break; case "sv": stopset = SwedishAnalyzer.getDefaultStopSet(); break; default: throw new UnsupportedOperationException("Language not supported yet"); } } return stopset; }
From source file:org.elasticsearch.analysis.common.SwedishAnalyzerProvider.java
License:Apache License
SwedishAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
super(indexSettings, name, settings);
analyzer = new SwedishAnalyzer(Analysis.parseStopWords(env, settings, SwedishAnalyzer.getDefaultStopSet()),
Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET));
analyzer.setVersion(version);//from www.j a va2 s .c o m
}
From source file:org.elasticsearch.index.analysis.SwedishAnalyzerProvider.java
License:Apache License
@Inject public SwedishAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env, @Assisted String name, @Assisted Settings settings) { super(index, indexSettings, name, settings); analyzer = new SwedishAnalyzer(version, Analysis.parseStopWords(env, settings, SwedishAnalyzer.getDefaultStopSet(), version), Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET, version)); }
From source file:org.omegat.tokenizer.LuceneSwedishTokenizer.java
License:Open Source License
@Override protected TokenStream getTokenStream(final String strOrig, final boolean stemsAllowed, final boolean stopWordsAllowed) { if (stemsAllowed) { Set<?> stopWords = stopWordsAllowed ? SwedishAnalyzer.getDefaultStopSet() : Collections.EMPTY_SET; return new SwedishAnalyzer(getBehavior(), stopWords).tokenStream("", new StringReader(strOrig)); } else {/*from www . j a v a 2 s . co m*/ return new StandardTokenizer(getBehavior(), new StringReader(strOrig)); } }