Package elki.distance.strings
Class NormalizedLevenshteinDistance
- java.lang.Object
-
- elki.distance.strings.NormalizedLevenshteinDistance
-
- All Implemented Interfaces:
Distance<java.lang.String>,PrimitiveDistance<java.lang.String>
@Description("Levenshtein distance, normalized by average string length.") @Reference(authors="V. I. Levenshtein", title="Binary codes capable of correcting deletions, insertions and reversals", booktitle="Soviet physics doklady 10", bibkey="journals/misc/Levenshtein66") public class NormalizedLevenshteinDistance extends java.lang.Object implements PrimitiveDistance<java.lang.String>
Levenshtein distance on strings, normalized by string length.Note: this is no longer a metric, the triangle inequality is violated. Example: d("ab","bc")=1, d("ab", "abc")+d("abc","bc")=0.4+0.4=0.8
Reference:
V. I. Levenshtein
Binary codes capable of correcting deletions, insertions and reversals.
Soviet physics doklady. Vol. 10. 1966.TODO: add case insensitive flag.
- Since:
- 0.6.0
- Author:
- Felix Stahlberg, Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNormalizedLevenshteinDistance.ParParameterization class.
-
Field Summary
Fields Modifier and Type Field Description static NormalizedLevenshteinDistanceSTATIC_SENSITIVEStatic instance, case sensitive.
-
Constructor Summary
Constructors Constructor Description NormalizedLevenshteinDistance()Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubledistance(java.lang.String o1, java.lang.String o2)Computes the distance between two given DatabaseObjects according to this distance function.booleanequals(java.lang.Object obj)SimpleTypeInformation<? super java.lang.String>getInputTypeRestriction()Get the input data type of the function.inthashCode()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.distance.Distance
isMetric, isSquared, isSymmetric
-
Methods inherited from interface elki.distance.PrimitiveDistance
instantiate
-
-
-
-
Field Detail
-
STATIC_SENSITIVE
public static final NormalizedLevenshteinDistance STATIC_SENSITIVE
Static instance, case sensitive.
-
-
Method Detail
-
distance
public double distance(java.lang.String o1, java.lang.String o2)Description copied from interface:PrimitiveDistanceComputes the distance between two given DatabaseObjects according to this distance function.- Specified by:
distancein interfacePrimitiveDistance<java.lang.String>- Parameters:
o1- first DatabaseObjecto2- second DatabaseObject- Returns:
- the distance between two given DatabaseObjects according to this distance function
-
getInputTypeRestriction
public SimpleTypeInformation<? super java.lang.String> getInputTypeRestriction()
Description copied from interface:DistanceGet the input data type of the function.- Specified by:
getInputTypeRestrictionin interfaceDistance<java.lang.String>- Specified by:
getInputTypeRestrictionin interfacePrimitiveDistance<java.lang.String>- Returns:
- Type restriction
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-