Class IntersectionSimilarity<T>

  • Type Parameters:
    T - the type of the elements extracted from the character sequence
    All Implemented Interfaces:
    SimilarityScore<IntersectionResult>

    public class IntersectionSimilarity<T>
    extends java.lang.Object
    implements SimilarityScore<IntersectionResult>
    Measures the intersection of two sets created from a pair of character sequences.

    It is assumed that the type T correctly conforms to the requirements for storage within a Set or HashMap. Ideally the type is immutable and implements Object.equals(Object) and Object.hashCode().

    Since:
    1.7
    See Also:
    Set, HashMap
    • Constructor Summary

      Constructors 
      Constructor Description
      IntersectionSimilarity​(java.util.function.Function<java.lang.CharSequence,​java.util.Collection<T>> converter)
      Create a new intersection similarity using the provided converter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IntersectionResult apply​(java.lang.CharSequence left, java.lang.CharSequence right)
      Calculates the intersection of two character sequences passed as input.
      • Methods inherited from class java.lang.Object

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

      • IntersectionSimilarity

        public IntersectionSimilarity​(java.util.function.Function<java.lang.CharSequence,​java.util.Collection<T>> converter)
        Create a new intersection similarity using the provided converter.

        If the converter returns a Set then the intersection result will not include duplicates. Any other Collection is used to produce a result that will include duplicates in the intersect and union.

        Parameters:
        converter - the converter used to create the elements from the characters
        Throws:
        java.lang.IllegalArgumentException - if the converter is null
    • Method Detail

      • apply

        public IntersectionResult apply​(java.lang.CharSequence left,
                                        java.lang.CharSequence right)
        Calculates the intersection of two character sequences passed as input.
        Specified by:
        apply in interface SimilarityScore<T>
        Parameters:
        left - first character sequence
        right - second character sequence
        Returns:
        The intersection result
        Throws:
        java.lang.IllegalArgumentException - if either input sequence is null