Example usage for org.apache.lucene.analysis.fr FrenchAnalyzer getDefaultStopSet

List of usage examples for org.apache.lucene.analysis.fr FrenchAnalyzer getDefaultStopSet

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.fr FrenchAnalyzer getDefaultStopSet.

Prototype

public static CharArraySet getDefaultStopSet() 

Source Link

Document

Returns an unmodifiable instance of the default stop-words set.

Usage

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.
 */// ww w. jav  a 2  s.  com
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 testGetFrenchPreBuiltAnalyzer() {
    CharArraySet stopwords = StandardStopwords.FRENCH.get();
    assertEquals("Expected another stopwords", FrenchAnalyzer.getDefaultStopSet(), stopwords);
}

From source file:ie.cmrc.smtx.lucene.analysis.EuropeanAnalyzer.java

License:Apache License

/**
 * Gets the stop words set for the provided language
 * @param language Two-letter code of a language
 * @return {@code CharArraySet} containing the stop words of the provided language.
 * If the provided language is not supported,then the Lucene standard stop words set
 * if returned.//w w  w . ja va2  s  .com
 */
protected CharArraySet getStopWordsSet(String language) {
    String lang = language;
    if (lang != null)
        lang = lang.trim().toLowerCase();
    CharArraySet charArraySet = cache.get(lang);
    if (charArraySet == null) {
        if (SUPPORTED_LANGUAGES.contains(lang)) {
            if (lang.equals(LANG_EN)) {
                charArraySet = EnglishAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_FR)) {
                charArraySet = FrenchAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_ES)) {
                charArraySet = SpanishAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_PT)) {
                charArraySet = PortugueseAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_IT)) {
                charArraySet = ItalianAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_DE)) {
                charArraySet = GermanAnalyzer.getDefaultStopSet();
            } else if (lang.equals(LANG_NO)) {
                charArraySet = NorwegianAnalyzer.getDefaultStopSet();
            }
        } else {
            charArraySet = StandardAnalyzer.STOP_WORDS_SET;
        }
        cache.put(lang, charArraySet);
    }
    return charArraySet;
}

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 {/*from   www .  j av a  2s. co  m*/
            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.FrenchAnalyzerProvider.java

License:Apache License

FrenchAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    analyzer = new FrenchAnalyzer(Analysis.parseStopWords(env, settings, FrenchAnalyzer.getDefaultStopSet()),
            Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET));
    analyzer.setVersion(version);/*from   ww w .j ava  2  s .c  o  m*/
}

From source file:org.elasticsearch.index.analysis.FrenchAnalyzerProvider.java

License:Apache License

@Inject
public FrenchAnalyzerProvider(Index index, @IndexSettings Settings indexSettings, Environment env,
        @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettings, name, settings);
    analyzer = new FrenchAnalyzer(version,
            Analysis.parseStopWords(env, settings, FrenchAnalyzer.getDefaultStopSet(), version),
            Analysis.parseStemExclusion(settings, CharArraySet.EMPTY_SET, version));
}

From source file:org.jahia.services.search.analyzer.FrenchSnowballAnalyzer.java

License:Open Source License

public FrenchSnowballAnalyzer() {
    super(new SnowballAnalyzer(Version.LUCENE_30, "French", FrenchAnalyzer.getDefaultStopSet()));
}

From source file:org.silverpeas.core.index.indexing.model.WAAnalyzer.java

License:Open Source License

/**
 * Returns a tokens stream built on top of the given reader.
 *
 *///from  w  w w  . j av  a  2s.c  om
@Override
protected TokenStreamComponents createComponents(final String s) {
    final Tokenizer source = new StandardTokenizer();
    // remove 's and . from token
    TokenStream result = new StandardFilter(source);
    result = new LowerCaseFilter(result);
    // remove some unexplicit terms
    result = new StopFilter(result, FrenchAnalyzer.getDefaultStopSet());
    // remove [cdjlmnst-qu]' from token
    result = new ElisionFilter(result, FrenchAnalyzer.DEFAULT_ARTICLES);
    if (snowballUsed) {
        // Important! Strings given to Snowball filter must contains accents
        // so accents must be removed after stemmer have done the job
        // ignoring singular/plural, male/female and conjugated forms
        result = new SnowballFilter(result, stemmer);
    }
    // remove accents
    result = new ASCIIFoldingFilter(result);
    return new TokenStreamComponents(source, result);
}