Example usage for org.apache.lucene.search.spell DirectSpellChecker getThresholdFrequency

List of usage examples for org.apache.lucene.search.spell DirectSpellChecker getThresholdFrequency

Introduction

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

Prototype

public float getThresholdFrequency() 

Source Link

Document

Get the minimal threshold of documents a term must appear for a match

Usage

From source file:org.codelibs.elasticsearch.search.suggest.phrase.DirectCandidateGenerator.java

License:Apache License

public DirectCandidateGenerator(DirectSpellChecker spellchecker, String field, SuggestMode suggestMode,
        IndexReader reader, double nonErrorLikelihood, int numCandidates, Analyzer preFilter,
        Analyzer postFilter, Terms terms) throws IOException {
    if (terms == null) {
        throw new IllegalArgumentException("generator field [" + field + "] doesn't exist");
    }/*  ww  w  .  j  av a 2  s .  c  o m*/
    this.spellchecker = spellchecker;
    this.field = field;
    this.numCandidates = numCandidates;
    this.suggestMode = suggestMode;
    this.reader = reader;
    final long dictSize = terms.getSumTotalTermFreq();
    this.useTotalTermFrequency = dictSize != -1;
    this.dictSize = dictSize == -1 ? reader.maxDoc() : dictSize;
    this.preFilter = preFilter;
    this.postFilter = postFilter;
    this.nonErrorLikelihood = nonErrorLikelihood;
    float thresholdFrequency = spellchecker.getThresholdFrequency();
    this.frequencyPlateau = thresholdFrequency >= 1.0f ? (int) thresholdFrequency
            : (int) (dictSize * thresholdFrequency);
    termsEnum = terms.iterator();
}

From source file:org.elasticsearch.search.suggest.phrase.DirectCandidateGenerator.java

License:Apache License

public DirectCandidateGenerator(DirectSpellChecker spellchecker, String field, SuggestMode suggestMode,
        IndexReader reader, double nonErrorLikelihood, int numCandidates, Analyzer preFilter,
        Analyzer postFilter, Terms terms) throws IOException {
    if (terms == null) {
        throw new ElasticsearchIllegalArgumentException("generator field [" + field + "] doesn't exist");
    }/*from  ww  w.  ja v a 2 s  . co  m*/
    this.spellchecker = spellchecker;
    this.field = field;
    this.numCandidates = numCandidates;
    this.suggestMode = suggestMode;
    this.reader = reader;
    final long dictSize = terms.getSumTotalTermFreq();
    this.useTotalTermFrequency = dictSize != -1;
    this.dictSize = dictSize == -1 ? reader.maxDoc() : dictSize;
    this.preFilter = preFilter;
    this.postFilter = postFilter;
    this.nonErrorLikelihood = nonErrorLikelihood;
    float thresholdFrequency = spellchecker.getThresholdFrequency();
    this.frequencyPlateau = thresholdFrequency >= 1.0f ? (int) thresholdFrequency
            : (int) (dictSize * thresholdFrequency);
    termsEnum = terms.iterator(null);
}