diff options
author | Rocky Madden <git@rockymadden.com> | 2012-11-09 15:36:59 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-11-09 15:36:59 -0700 |
commit | 60cbc08776285e5bef6aae41b7a323cb556406ff (patch) | |
tree | ec65a429d0271a8b3a51684d9cbfab8ac590a803 /core/source/test | |
parent | 9f8194dc286ee89275cf37b87910dca240945b3e (diff) | |
download | stringmetric-60cbc08776285e5bef6aae41b7a323cb556406ff.tar.gz stringmetric-60cbc08776285e5bef6aae41b7a323cb556406ff.tar.bz2 stringmetric-60cbc08776285e5bef6aae41b7a323cb556406ff.zip |
Changed compare implemention. It is now required to specify the size of the n-gram. Typically, this was 2.
Diffstat (limited to 'core/source/test')
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetricSpec.scala | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/core/source/test/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetricSpec.scala index 0e8b3a7..163bab5 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetricSpec.scala @@ -10,37 +10,51 @@ final class DiceSorensenMetricSpec extends ScalaTest { "compare method" when passed { "empty arguments" should returns { "None" in { - DiceSorensenMetric.compare("", "").isDefined should be (false) - DiceSorensenMetric.compare("abc", "").isDefined should be (false) - DiceSorensenMetric.compare("", "xyz").isDefined should be (false) + DiceSorensenMetric.compare("", "")(1).isDefined should be (false) + DiceSorensenMetric.compare("abc", "")(1).isDefined should be (false) + DiceSorensenMetric.compare("", "xyz")(1).isDefined should be (false) } } "equal arguments" should returns { "1" in { - DiceSorensenMetric.compare("abc", "abc").get should be (1) + DiceSorensenMetric.compare("abc", "abc")(1).get should be (1) + DiceSorensenMetric.compare("abc", "abc")(2).get should be (1) + DiceSorensenMetric.compare("abc", "abc")(3).get should be (1) } } "unequal arguments" should returns { "0" in { - DiceSorensenMetric.compare("abc", "xyz").get should be (0) + DiceSorensenMetric.compare("abc", "xyz")(1).get should be (0) + DiceSorensenMetric.compare("abc", "xyz")(2).get should be (0) + DiceSorensenMetric.compare("abc", "xyz")(3).get should be (0) } } "invalid arguments" should returns { "Double indicating distance" in { - DiceSorensenMetric.compare("n", "naght").get should be (0) - DiceSorensenMetric.compare("night", "n").get should be (0) + DiceSorensenMetric.compare("n", "naght")(2).get should be (0) + DiceSorensenMetric.compare("night", "n")(2).get should be (0) + DiceSorensenMetric.compare("ni", "naght")(3).get should be (0) + DiceSorensenMetric.compare("night", "na")(3).get should be (0) } } "valid arguments" should returns { "Double indicating distance" in { - DiceSorensenMetric.compare("night", "nacht").get should be (0.25) - DiceSorensenMetric.compare("night", "naght").get should be (0.5) - DiceSorensenMetric.compare("context", "contact").get should be (0.5) - DiceSorensenMetric.compare("contextcontext", "contact").get should be (0.3157894736842105) - DiceSorensenMetric.compare("context", "contactcontact").get should be (0.3157894736842105) - DiceSorensenMetric.compare("ht", "nacht").get should be (0.4) - DiceSorensenMetric.compare("xp", "nacht").get should be (0) - DiceSorensenMetric.compare("ht", "hththt").get should be (0.3333333333333333) + DiceSorensenMetric.compare("night", "nacht")(1).get should be (0.6) + DiceSorensenMetric.compare("night", "naght")(1).get should be (0.8) + DiceSorensenMetric.compare("context", "contact")(1).get should be (0.7142857142857143) + + DiceSorensenMetric.compare("night", "nacht")(2).get should be (0.25) + DiceSorensenMetric.compare("night", "naght")(2).get should be (0.5) + DiceSorensenMetric.compare("context", "contact")(2).get should be (0.5) + DiceSorensenMetric.compare("contextcontext", "contact")(2).get should be (0.3157894736842105) + DiceSorensenMetric.compare("context", "contactcontact")(2).get should be (0.3157894736842105) + DiceSorensenMetric.compare("ht", "nacht")(2).get should be (0.4) + DiceSorensenMetric.compare("xp", "nacht")(2).get should be (0) + DiceSorensenMetric.compare("ht", "hththt")(2).get should be (0.3333333333333333) + + DiceSorensenMetric.compare("night", "nacht")(3).get should be (0) + DiceSorensenMetric.compare("night", "naght")(3).get should be (0.3333333333333333) + DiceSorensenMetric.compare("context", "contact")(3).get should be (0.4) } } } |