Class DamerauLevenshteinDistance

    • Constructor Summary

      Constructors 
      Constructor Description
      DamerauLevenshteinDistance()
      Constructs a default instance that uses a version of the algorithm that does not use a threshold parameter.
      DamerauLevenshteinDistance​(java.lang.Integer threshold)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Integer apply​(java.lang.CharSequence left, java.lang.CharSequence right)
      Computes the Damerau-Levenshtein distance between two Strings.
      <E> java.lang.Integer apply​(SimilarityInput<E> left, SimilarityInput<E> right)
      Computes the Damerau-Levenshtein distance between two inputs.
      java.lang.Integer getThreshold()
      Gets the distance threshold.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.BiFunction

        andThen
    • Constructor Detail

      • DamerauLevenshteinDistance

        public DamerauLevenshteinDistance()
        Constructs a default instance that uses a version of the algorithm that does not use a threshold parameter.
      • DamerauLevenshteinDistance

        public DamerauLevenshteinDistance​(java.lang.Integer threshold)
        Constructs a new instance. If the threshold is not null, distance calculations will be limited to a maximum length. If the threshold is null, the unlimited version of the algorithm will be used.
        Parameters:
        threshold - If this is null then distances calculations will not be limited. This may not be negative.
    • Method Detail

      • apply

        public java.lang.Integer apply​(java.lang.CharSequence left,
                                       java.lang.CharSequence right)
        Computes the Damerau-Levenshtein distance between two Strings.

        A higher score indicates a greater distance.

        Specified by:
        apply in interface java.util.function.BiFunction<java.lang.CharSequence,​java.lang.CharSequence,​java.lang.Integer>
        Specified by:
        apply in interface ObjectSimilarityScore<java.lang.CharSequence,​java.lang.Integer>
        Specified by:
        apply in interface SimilarityScore<java.lang.Integer>
        Parameters:
        left - the first input, must not be null.
        right - the second input, must not be null.
        Returns:
        result distance, or -1 if threshold is exceeded.
        Throws:
        java.lang.IllegalArgumentException - if either String input null.
      • apply

        public <E> java.lang.Integer apply​(SimilarityInput<E> left,
                                           SimilarityInput<E> right)
        Computes the Damerau-Levenshtein distance between two inputs.

        A higher score indicates a greater distance.

        Type Parameters:
        E - The type of similarity score unit.
        Parameters:
        left - the first input, must not be null.
        right - the second input, must not be null.
        Returns:
        result distance, or -1 if threshold is exceeded.
        Throws:
        java.lang.IllegalArgumentException - if either String input null.
        Since:
        1.13.0
      • getThreshold

        public java.lang.Integer getThreshold()
        Gets the distance threshold.
        Returns:
        The distance threshold.