Class EditDistanceComparator

  • All Implemented Interfaces:
    Comparator

    public class EditDistanceComparator
    extends AbstractComparator
    Oracle Comparator that uses the Levenshtein Edit Distance to determine whether two states are equivalent.
    • Field Detail

      • threshold

        private double threshold
    • Constructor Detail

      • EditDistanceComparator

        public EditDistanceComparator()
        Default constructor with edit distance threshold = 1.
      • EditDistanceComparator

        public EditDistanceComparator​(double threshold)
        Parameters:
        threshold - the edit distance threshold. 1 is no difference, 0 is totally different
    • Method Detail

      • getThreshold

        public double getThreshold()
        Returns:
        the threshold
      • setThreshold

        public void setThreshold​(double threshold)
        Parameters:
        threshold - the threshold to set
      • isClone

        boolean isClone​(String str1,
                        String str2,
                        double thresholdCoefficient)
        Parameters:
        str1 - the first string.
        str2 - the second string.
        thresholdCoefficient - the threshold coefficient: must be between 0.0-1.0.
        Returns:
        true if the Levenshtein distance is lower than or equal to the computed threshold.
      • getThreshold

        double getThreshold​(String x,
                            String y,
                            double p)
        Calculate a threshold.
        Parameters:
        x - first string.
        y - second string.
        p - the threshold coefficient.
        Returns:
        2 maxLength(x, y) (1-p)