org.apache.lucene.search.spell
Class LuceneLevenshteinDistance

java.lang.Object
  extended by org.apache.lucene.search.spell.LuceneLevenshteinDistance
All Implemented Interfaces:
StringDistance

public final class LuceneLevenshteinDistance
extends Object
implements StringDistance

Damerau-Levenshtein (optimal string alignment) implemented in a consistent way as Lucene's FuzzyTermsEnum with the transpositions option enabled. Notes:

NOTE: this class is not particularly efficient. It is only intended for merging results from multiple DirectSpellCheckers.


Constructor Summary
LuceneLevenshteinDistance()
          Creates a new comparator, mimicing the behavior of Lucene's internal edit distance.
 
Method Summary
 float getDistance(String target, String other)
          Returns a float between 0 and 1 based on how similar the specified strings are to one another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneLevenshteinDistance

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

Method Detail

getDistance

public float getDistance(String target,
                         String other)
Description copied from interface: StringDistance
Returns a float between 0 and 1 based on how similar the specified strings are to one another. Returning a value of 1 means the specified strings are identical and 0 means the string are maximally different.

Specified by:
getDistance in interface StringDistance
Parameters:
target - The first string.
other - The second string.
Returns:
a float between 0 and 1 based on how similar the specified strings are to one another.


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.