Example usage for org.apache.lucene.search.spell WordBreakSpellChecker WordBreakSpellChecker

List of usage examples for org.apache.lucene.search.spell WordBreakSpellChecker WordBreakSpellChecker

Introduction

In this page you can find the example usage for org.apache.lucene.search.spell WordBreakSpellChecker WordBreakSpellChecker.

Prototype

public WordBreakSpellChecker() 

Source Link

Document

Creates a new spellchecker with default configuration values

Usage

From source file:org.apache.solr.spelling.WordBreakSolrSpellChecker.java

License:Apache License

@Override
public String init(@SuppressWarnings("unchecked") NamedList config, SolrCore core) {
    String name = super.init(config, core);
    combineWords = boolParam(config, PARAM_COMBINE_WORDS);
    breakWords = boolParam(config, PARAM_BREAK_WORDS);
    wbsp = new WordBreakSpellChecker();
    String bstb = strParam(config, PARAM_BREAK_SUGGESTION_TIE_BREAKER);
    if (bstb != null) {
        bstb = bstb.toUpperCase(Locale.ROOT);
        if (bstb.equals(BreakSuggestionTieBreaker.SUM_FREQ.name())) {
            sortMethod = BreakSuggestionSortMethod.NUM_CHANGES_THEN_SUMMED_FREQUENCY;
        } else if (bstb.equals(BreakSuggestionTieBreaker.MAX_FREQ.name())) {
            sortMethod = BreakSuggestionSortMethod.NUM_CHANGES_THEN_MAX_FREQUENCY;
        } else {//from  w  ww .  ja v  a 2 s.c om
            throw new IllegalArgumentException(
                    "Invalid value for parameter " + PARAM_BREAK_SUGGESTION_TIE_BREAKER + " : " + bstb);
        }
    } else {
        sortMethod = BreakSuggestionSortMethod.NUM_CHANGES_THEN_MAX_FREQUENCY;
    }
    int mc = intParam(config, PARAM_MAX_CHANGES);
    if (mc > 0) {
        wbsp.setMaxChanges(mc);
    }
    int mcl = intParam(config, PARAM_MAX_COMBINE_WORD_LENGTH);
    if (mcl > 0) {
        wbsp.setMaxCombineWordLength(mcl);
    }
    int mbwl = intParam(config, PARAM_MIN_BREAK_WORD_LENGTH);
    if (mbwl > 0) {
        wbsp.setMinBreakWordLength(mbwl);
    }
    int me = intParam(config, PARAM_MAX_EVALUATIONS);
    if (me > 0) {
        wbsp.setMaxEvaluations(me);
    }
    int msf = intParam(config, PARAM_MIN_SUGGESTION_FREQUENCY);
    if (msf > 0) {
        wbsp.setMinSuggestionFrequency(msf);
    }
    return name;
}