Example usage for org.apache.lucene.analysis.fa PersianAnalyzer getDefaultStopSet

List of usage examples for org.apache.lucene.analysis.fa PersianAnalyzer getDefaultStopSet

Introduction

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

Prototype

public static CharArraySet getDefaultStopSet() 

Source Link

Document

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

Usage

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  w  ww. ja  v a 2 s.  c  o  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.crosswire.jsword.index.lucene.analysis.PersianLuceneAnalyzer.java

License:Open Source License

public PersianLuceneAnalyzer() throws IOException {
    stopSet = PersianAnalyzer.getDefaultStopSet();
}

From source file:org.elasticsearch.analysis.common.PersianAnalyzerProvider.java

License:Apache License

PersianAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    analyzer = new PersianAnalyzer(Analysis.parseStopWords(env, settings, PersianAnalyzer.getDefaultStopSet()));
    analyzer.setVersion(version);//from w w  w . j  a  va  2s .  c om
}

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

License:Apache License

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