Package org.apache.lucene.search.spell
Class JaroWinklerDistance
- java.lang.Object
-
- org.apache.lucene.search.spell.JaroWinklerDistance
-
- All Implemented Interfaces:
StringDistance
public class JaroWinklerDistance extends java.lang.Object implements StringDistance
Similarity measure for short strings such as person names.
-
-
Field Summary
Fields Modifier and Type Field Description private floatthreshold
-
Constructor Summary
Constructors Constructor Description JaroWinklerDistance()Creates a new distance metric with the default threshold for the Jaro Winkler bonus (0.7)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)floatgetDistance(java.lang.String s1, java.lang.String s2)Returns a float between 0 and 1 based on how similar the specified strings are to one another.floatgetThreshold()Returns the current value of the threshold used for adding the Winkler bonus.inthashCode()private int[]matches(java.lang.String s1, java.lang.String s2)voidsetThreshold(float threshold)Sets the threshold used to determine when Winkler bonus should be used.java.lang.StringtoString()
-
-
-
Constructor Detail
-
JaroWinklerDistance
public JaroWinklerDistance()
Creates a new distance metric with the default threshold for the Jaro Winkler bonus (0.7)- See Also:
setThreshold(float)
-
-
Method Detail
-
matches
private int[] matches(java.lang.String s1, java.lang.String s2)
-
getDistance
public float getDistance(java.lang.String s1, java.lang.String s2)Description copied from interface:StringDistanceReturns 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:
getDistancein interfaceStringDistance- Parameters:
s1- The first string.s2- The second string.- Returns:
- a float between 0 and 1 based on how similar the specified strings are to one another.
-
setThreshold
public void setThreshold(float threshold)
Sets the threshold used to determine when Winkler bonus should be used. Set to a negative value to get the Jaro distance.- Parameters:
threshold- the new value of the threshold
-
getThreshold
public float getThreshold()
Returns the current value of the threshold used for adding the Winkler bonus. The default value is 0.7.- Returns:
- the current value of the threshold
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-