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 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 -
Method Summary
Modifier and TypeMethodDescriptionstatic intcalculateDistance(CharSequence source, CharSequence target) Calculates the string distance between source and target strings using the Damerau-Levenshtein algorithm.floatgetDistance(String s1, String s2)
-
Constructor Details
-
DamerauLevenshteinDistance
public DamerauLevenshteinDistance()
-
-
Method Details
-
getDistance
- Specified by:
getDistancein interfaceorg.apache.lucene.search.spell.StringDistance
-
calculateDistance
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:
IllegalArgumentException- If either source or target is null.
-