Class SorensenDice

    • Constructor Summary

      Constructors 
      Constructor Description
      SorensenDice()
      Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index.
      SorensenDice​(int k)
      Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double distance​(java.lang.String s1, java.lang.String s2)
      Returns 1 - similarity.
      double similarity​(java.lang.String s1, java.lang.String s2)
      Similarity is computed as 2 * |A inter B| / (|A| + |B|).
      • Methods inherited from class java.lang.Object

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

      • SorensenDice

        public SorensenDice​(int k)
        Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index. The strings are first converted to boolean sets of k-shingles (sequences of k characters), then the similarity is computed as 2 * |A inter B| / (|A| + |B|). Attention: Sorensen-Dice distance (and similarity) does not satisfy triangle inequality.
        Parameters:
        k -
      • SorensenDice

        public SorensenDice()
        Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index. The strings are first converted to boolean sets of k-shingles (sequences of k characters), then the similarity is computed as 2 * |A inter B| / (|A| + |B|). Attention: Sorensen-Dice distance (and similarity) does not satisfy triangle inequality. Default k is 3.
    • Method Detail

      • similarity

        public final double similarity​(java.lang.String s1,
                                       java.lang.String s2)
        Similarity is computed as 2 * |A inter B| / (|A| + |B|).
        Specified by:
        similarity in interface StringSimilarity
        Parameters:
        s1 - The first string to compare.
        s2 - The second string to compare.
        Returns:
        The computed Sorensen-Dice similarity.
        Throws:
        java.lang.NullPointerException - if s1 or s2 is null.
      • distance

        public final double distance​(java.lang.String s1,
                                     java.lang.String s2)
        Returns 1 - similarity.
        Specified by:
        distance in interface StringDistance
        Parameters:
        s1 - The first string to compare.
        s2 - The second string to compare.
        Returns:
        1.0 - the computed similarity
        Throws:
        java.lang.NullPointerException - if s1 or s2 is null.