Java 类org.apache.lucene.search.spell.WordBreakSpellChecker 实例源码

项目:search    文件:WordBreakSolrSpellChecker.java   
@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 {
      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;
}
项目:NYBC    文件:WordBreakSolrSpellChecker.java   
@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 {
      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;
}
项目:search-core    文件:WordBreakSolrSpellChecker.java   
@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 {
      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;
}
项目:read-open-source-code    文件:WordBreakSolrSpellChecker.java   
@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 {
      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;
}
项目:read-open-source-code    文件:WordBreakSolrSpellChecker.java   
@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 {
      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;
}