List of usage examples for org.apache.lucene.search.spell LuceneLevenshteinDistance LuceneLevenshteinDistance
public LuceneLevenshteinDistance()
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); } }