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

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

Introduction

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

Prototype

public LuceneLevenshteinDistance() 

Source Link

Document

Creates a new comparator, mimicing the behavior of Lucene's internal edit distance.

Usage

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

License:Apache License

private static StringDistance resolveDistance(String distanceVal) {
    distanceVal = distanceVal.toLowerCase(Locale.US);
    if ("internal".equals(distanceVal)) {
        return DirectSpellChecker.INTERNAL_LEVENSHTEIN;
    } else if ("damerau_levenshtein".equals(distanceVal) || "damerauLevenshtein".equals(distanceVal)) {
        return new LuceneLevenshteinDistance();
    } else if ("levenstein".equals(distanceVal)) {
        return new LevensteinDistance();
        // TODO Jaro and Winkler are 2 people - so apply same naming logic
        // as damerau_levenshtein
    } else if ("jarowinkler".equals(distanceVal)) {
        return new JaroWinklerDistance();
    } else if ("ngram".equals(distanceVal)) {
        return new NGramDistance();
    } else {/*from  w w  w.  j a  va 2s . com*/
        throw new IllegalArgumentException("Illegal distance option " + distanceVal);
    }
}

From source file:org.elasticsearch.search.suggest.SuggestUtils.java

License:Apache License

public static StringDistance resolveDistance(String distanceVal) {
    if ("internal".equals(distanceVal)) {
        return DirectSpellChecker.INTERNAL_LEVENSHTEIN;
    } else if ("damerau_levenshtein".equals(distanceVal) || "damerauLevenshtein".equals(distanceVal)) {
        return new LuceneLevenshteinDistance();
    } else if ("levenstein".equals(distanceVal)) {
        return new LevensteinDistance();
        //TODO Jaro and Winkler are 2 people - so apply same naming logic as damerau_levenshtein  
    } else if ("jarowinkler".equals(distanceVal)) {
        return new JaroWinklerDistance();
    } else if ("ngram".equals(distanceVal)) {
        return new NGramDistance();
    } else {/* w w  w .ja v a  2  s.c  o  m*/
        throw new ElasticsearchIllegalArgumentException("Illegal distance option " + distanceVal);
    }
}