com.emarsys.ecommon.collections.fuzzy
Interface FuzzyComparable<T>

All Known Implementing Classes:
AlphabeticalTable, AlphaNumericTriageTable, FuzzyFingerPrint, MimeText, PrefixTable, TableBasedFingerprint, Text, TextFingerprint, WordTable

public interface FuzzyComparable<T>

Compares its two arguments for similarity. Returns a floating point number between zero and one representing the degree of similarity.

This interface imposes a NO ordering on the objects of each class that implements it.

The fuzzy comparison for a class C is said to be consistent with equals if and only if (e1.compareTo((Object)e2) == 0) has the same boolean value as e1.equals((Object)e2) for almost every e1 and e2 of class C. Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.

The implementor should strive for ensuring that the following properties:

  • Pseudo reflexivity: compare(x, x) >= 1-E
  • Pseudo symetry: abs(compare(x, y) - compare(y, x)) <= E
  • Pseudo transitivity: compare(x,y) <= 1-E and compare(y,z) <= 1-E implies compare(x,z) < 1-E with E as small as possible for all x, y, z.

    Furhtermore compare(x, y) must throw an exception iff compare(y, x) throws an exception.

    It is strongly recommended (though not required) that the comparison is consistent with equals. So it is generally the case, but not strictly required that (compare(x, y)==1) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact.

    Author:
    Michael "kULO" Kulovits
    See Also:
    FuzzyComparator, Comparator, Comparable, Object.equals(Object)

    Method Summary
     float compareTo(T o)
              Compares its two arguments for similarity.
     

    Method Detail

    compareTo

    float compareTo(T o)
                    throws FuzzyException
    Compares its two arguments for similarity. Returns a floating point number between zero and one representing the degree of similarity.

    The implementor should strive for ensuring that the following properties:

  • Pseudo reflexivity: compare(x, x) >= 1-E
  • Pseudo symetry: abs(compare(x, y) - compare(y, x)) <= E
  • Pseudo transitivity: compare(x,y) <= 1-E and compare(y,z) <= 1-E implies compare(x,z) < 1-E with E as small as possible for all x, y, z.

    Furhtermore compare(x, y) must throw an exception iff compare(y, x) throws an exception.

    It is strongly recommended (though not required) that the comparison is consistent with equals. So it is generally the case, but not strictly required that (compare(x, y)==1) == (x.equals(y)). Generally speaking, any comparator that violates this condition should clearly indicate this fact.

    Parameters:
    o1 - the first object to be compared.
    o2 - the second object to be compared.
    Returns:
    a float between 0 and 1 where the latter means "very similar" and the first "not similar".
    Throws:
    FuzzyException - - if an error occured.


  • Copyright © 2010 emarsys AG. All Rights Reserved.