Class 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
    • 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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DamerauLevenshteinDistance

        public DamerauLevenshteinDistance()
    • Method Detail

      • getDistance

        public float getDistance​(java.lang.String s1,
                                 java.lang.String s2)
        Specified by:
        getDistance in interface org.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.