Package com.jalios.jcms.categorycleaner
Class DamerauLevenshteinDistance
- java.lang.Object
-
- com.jalios.jcms.categorycleaner.DamerauLevenshteinDistance
-
- All Implemented Interfaces:
org.apache.lucene.search.spell.StringDistance
public class DamerauLevenshteinDistance extends java.lang.Object implements org.apache.lucene.search.spell.StringDistance
From https://github.com/crwohlfeil/damerau-levenshtein/blob/master/src/main/java/com/codeweasel/DamerauLevenshtein.java- Since:
- jcms-10.0.4
-
-
Constructor Summary
Constructors Constructor Description DamerauLevenshteinDistance()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
calculateDistance(java.lang.CharSequence source, java.lang.CharSequence target)
Calculates the string distance between source and target strings using the Damerau-Levenshtein algorithm.float
getDistance(java.lang.String s1, java.lang.String s2)
-
-
-
Method Detail
-
getDistance
public float getDistance(java.lang.String s1, java.lang.String s2)
- Specified by:
getDistance
in interfaceorg.apache.lucene.search.spell.StringDistance
-
calculateDistance
public static int calculateDistance(java.lang.CharSequence source, java.lang.CharSequence target)
Calculates the string distance between source and target strings using the Damerau-Levenshtein algorithm. The distance is case-sensitive.- Parameters:
source
- The source String.target
- The target String.- Returns:
- The distance between source and target strings.
- Throws:
java.lang.IllegalArgumentException
- If either source or target is null.
-
-