diff options
author | Rocky Madden <git@rockymadden.com> | 2012-10-15 21:39:00 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-10-15 21:39:00 -0600 |
commit | fca3092370731e8cae29a4e52ebc33488e9ec3a1 (patch) | |
tree | a5bc0dc7a1b73a8d378d5f84f4aa23fe22220742 | |
parent | 78e92440eaa994292b2ebb91bc5b517ed27c8e40 (diff) | |
download | stringmetric-fca3092370731e8cae29a4e52ebc33488e9ec3a1.tar.gz stringmetric-fca3092370731e8cae29a4e52ebc33488e9ec3a1.tar.bz2 stringmetric-fca3092370731e8cae29a4e52ebc33488e9ec3a1.zip |
Metric and StringMetric compare methods now return Option[T]. This is to better communicate when it is not possible to perform metric comparisions.
12 files changed, 131 insertions, 120 deletions
diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala index f633322..874f3aa 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroMetric.scala @@ -47,6 +47,6 @@ object jaroMetric extends Command { override def execute(options: OptionMap): Unit = { val strings = options('dashless).split(" ") - println(JaroMetric.compare(strings(0), strings(1))(new StringCleanerDelegate with CaseStringCleaner).toString) + println(JaroMetric.compare(strings(0), strings(1))(new StringCleanerDelegate with CaseStringCleaner).getOrElse("0.0").toString) } }
\ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala index 8590ac9..ea1b8a6 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/jaroWinklerMetric.scala @@ -47,6 +47,6 @@ object jaroWinklerMetric extends Command { override def execute(options: OptionMap): Unit = { val strings = options('dashless).split(" ") - println(JaroWinklerMetric.compare(strings(0), strings(1))(new StringCleanerDelegate with CaseStringCleaner).toString) + println(JaroWinklerMetric.compare(strings(0), strings(1))(new StringCleanerDelegate with CaseStringCleaner).getOrElse("0.0").toString) } }
\ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala index 6f6f9ec..5a44395 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/command/soundexMetric.scala @@ -47,6 +47,6 @@ object soundexMetric extends Command { override def execute(options: OptionMap): Unit = { val strings = options('dashless).split(" ") - println(SoundexMetric.compare(strings(0), strings(1))(new StringCleanerDelegate).toString) + println(SoundexMetric.compare(strings(0), strings(1))(new StringCleanerDelegate).getOrElse("false").toString) } }
\ No newline at end of file diff --git a/cli/source/test/scala/org/hashtree/stringmetric/cli/command/soundexMetricSpec.scala b/cli/source/test/scala/org/hashtree/stringmetric/cli/command/soundexMetricSpec.scala index c71b1ea..80a0a50 100755 --- a/cli/source/test/scala/org/hashtree/stringmetric/cli/command/soundexMetricSpec.scala +++ b/cli/source/test/scala/org/hashtree/stringmetric/cli/command/soundexMetricSpec.scala @@ -25,6 +25,13 @@ final class soundexMetricSpec extends ScalaTest { out.toString should equal ("false\n") out.reset() + + Console.withOut(out)( + soundexMetric.main(Array("--unitTest", "--debug", "1", "1")) + ) + + out.toString should equal ("false\n") + out.reset() } } "no dashless arguments" should throws { diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala index 903126a..bd2b468 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala @@ -9,26 +9,26 @@ import scala.math * distance in these scenarios. */ object JaroMetric extends StringMetric { - override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Float = { + override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Float] = { val ca1 = stringCleaner.clean(charArray1) val ca2 = stringCleaner.clean(charArray2) - // Return 0 if either character array lacks length. - if (ca1.length == 0 || ca2.length == 0) return 0f + // Return None if either character array lacks length. + if (ca1.length == 0 || ca2.length == 0) return None val mt = `match`((ca1, ca2)) val ms = scoreMatches((mt._1, mt._2)) val ts = scoreTranspositions((mt._1, mt._2)) // Return 0 if matches score is 0. - if (ms == 0) return 0f + if (ms == 0) return Some(0f) - ((ms.toFloat / ca1.length) + (ms.toFloat / ca2.length) + ((ms.toFloat - ts) / ms)) / 3 + Some(((ms.toFloat / ca1.length) + (ms.toFloat / ca2.length) + ((ms.toFloat - ts) / ms)) / 3) } - override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Float = { + override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Option[Float] = { // Return 1 if strings are an exact match. - if (string1.length > 0 && string1 == string2) return 1f + if (string1.length > 0 && string1 == string2) return Some(1f) compare(stringCleaner.clean(string1.toCharArray), stringCleaner.clean(string2.toCharArray))(new StringCleanerDelegate) } diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala index aab8cd9..892da04 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala @@ -6,18 +6,23 @@ package org.hashtree.stringmetric * penalized distance in these scenarios (e.g. comparing henka and henkan distance is 0.9666 versus the typical 0.9722). */ object JaroWinklerMetric extends StringMetric { - override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Float = { + override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Float] = { val ca1 = stringCleaner.clean(charArray1) val ca2 = stringCleaner.clean(charArray2) - val jaro = JaroMetric.compare(ca1, ca2)(new StringCleanerDelegate) - val prefix = ca1.zip(ca2).takeWhile(t => t._1 == t._2).map(_._1) - jaro + ((if (prefix.length <= 4) prefix.length else 4) * 0.1f * (1 - jaro)) + JaroMetric.compare(ca1, ca2)(new StringCleanerDelegate) match { + case Some(jaro) => { + val prefix = ca1.zip(ca2).takeWhile(t => t._1 == t._2).map(_._1) + + Some(jaro + ((if (prefix.length <= 4) prefix.length else 4) * 0.1f * (1 - jaro))) + } + case None => None + } } - override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Float = { + override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Option[Float] = { // Return 1 if strings are an exact match. - if (string1.length > 0 && string1 == string2) return 1f + if (string1.length > 0 && string1 == string2) return Some(1f) compare(stringCleaner.clean(string1.toCharArray), stringCleaner.clean(string2.toCharArray))(new StringCleanerDelegate) } diff --git a/core/source/core/scala/org/hashtree/stringmetric/Metric.scala b/core/source/core/scala/org/hashtree/stringmetric/Metric.scala index 86017b3..218285f 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/Metric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/Metric.scala @@ -2,5 +2,5 @@ package org.hashtree.stringmetric /** Marks those which leverage traits of a metric. */ trait Metric[T, C] { - def compare(t1: T, t2: T)(implicit c: C): AnyVal + def compare(t1: T, t2: T)(implicit c: C): Option[AnyVal] }
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala index 322d54e..358a57f 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala @@ -4,19 +4,19 @@ import scala.annotation.tailrec /** An implementation of the Soundex [[org.hashtree.stringmetric.StringMetric]]. */ object SoundexMetric extends StringMetric { - override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Boolean = { + override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Boolean] = { val se1 = if (charArray1.length > 0) soundex(charArray1) else None val se2 = if (charArray2.length > 0) soundex(charArray2) else None - (se1.isDefined && se2.isDefined && se1.get == se2.get) + if (!se1.isDefined || !se2.isDefined) None else Some(se1.get == se2.get) } - override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Boolean = { + override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Option[Boolean] = { compare(string1.toCharArray, string2.toCharArray) } - private[this] def soundex(charArray: Array[Char]) = { - require(charArray.length > 0) + private[this] def soundex(ca: Array[Char]) = { + require(ca.length > 0) @tailrec def letter(ca: Array[Char], i: Int): Option[Tuple2[Char, Int]] = { @@ -72,12 +72,12 @@ object SoundexMetric extends StringMetric { code(i.tail, c, if (a != '\0') o :+ a else o) } - letter(charArray, 0) match { + letter(ca, 0) match { case Some(l) => { - if (charArray.length - 1 == l._2) Some(l._1 + "000") + if (ca.length - 1 == l._2) Some(l._1 + "000") else { Some( - code(charArray.takeRight(charArray.length - (l._2 + 1)), + code(ca.takeRight(ca.length - (l._2 + 1)), l._1, // Pass first letter. Array(l._1) // Pass array with first letter. ).mkString.padTo(4, '0') diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala index 960540e..115a9e9 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala @@ -2,5 +2,5 @@ package org.hashtree.stringmetric /** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.Metric]]. */ trait StringMetric extends Metric[String, StringCleaner] { - def compare(ca1: Array[Char], ca2: Array[Char])(implicit stringCleaner: StringCleaner): AnyVal + def compare(ca1: Array[Char], ca2: Array[Char])(implicit stringCleaner: StringCleaner): Option[AnyVal] }
\ No newline at end of file diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala index a7059a3..902606e 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala @@ -9,45 +9,44 @@ final class JaroMetricSpec extends ScalaTest { "compare method" when passed { "valid arguments" should returns { "Float indicating distance" in { - JaroMetric.compare("abc", "abc") should be (1.0f) - JaroMetric.compare("abc", "xyz") should be (0.0f) - JaroMetric.compare("abc", "") should be (0.0f) - JaroMetric.compare("", "xyz") should be (0.0f) - JaroMetric.compare("", "") should be (0.0f) - JaroMetric.compare("a", "a") should be (1.0f) - - JaroMetric.compare("aa", "a") should be (0.8333333f) - JaroMetric.compare("a", "aa") should be (0.8333333f) - - JaroMetric.compare("veryveryverylong", "v") should be (0.6875f) - JaroMetric.compare("v", "veryveryverylong") should be (0.6875f) - - JaroMetric.compare("martha", "marhta") should be (0.9444444f) - JaroMetric.compare("dwayne", "duane") should be (0.82222223f) - JaroMetric.compare("dixon", "dicksonx") should be (0.76666665f) - JaroMetric.compare("abcvwxyz", "cabvwxyz") should be (0.9583333f) - JaroMetric.compare("jones", "johnson") should be (0.79047614f) - JaroMetric.compare("henka", "henkan") should be (0.9444444f) - JaroMetric.compare("fvie", "ten") should be (0.0f) - - JaroMetric.compare("zac ephron", "zac efron") should be > - JaroMetric.compare("zac ephron", "kai ephron") - JaroMetric.compare("brittney spears", "britney spears") should be > - JaroMetric.compare("brittney spears", "brittney startzman") - - JaroMetric.compare("m a r t h a", "m a r h t a") should be (0.9444444f) - - JaroMetric.compare("d w a y n e", "d u a n e") should be (0.82222223f) - JaroMetric.compare("d i x o n", "d i c k s o n x") should be (0.76666665f) - JaroMetric.compare("a b c v w x y z", "c a b v w x y z") should be (0.9583333f) - JaroMetric.compare("j o n e s", "j o h n s o n") should be (0.79047614f) - JaroMetric.compare("h e n k a", "h e n k a n") should be (0.9444444f) - JaroMetric.compare("f v i e", "t e n") should be (0.0f) - - JaroMetric.compare("z a c e p h r o n", "z a c e f r o n") should be > - JaroMetric.compare("z a c e p h r o n", "k a i e p h r o n") - JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s") should be > - JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n") + JaroMetric.compare("abc", "abc").get should be (1.0f) + JaroMetric.compare("abc", "xyz").get should be (0.0f) + JaroMetric.compare("abc", "").isDefined should be (false) + JaroMetric.compare("", "xyz").isDefined should be (false) + JaroMetric.compare("", "").isDefined should be (false) + JaroMetric.compare("a", "a").get should be (1.0f) + + JaroMetric.compare("aa", "a").get should be (0.8333333f) + JaroMetric.compare("a", "aa").get should be (0.8333333f) + + JaroMetric.compare("veryveryverylong", "v").get should be (0.6875f) + JaroMetric.compare("v", "veryveryverylong").get should be (0.6875f) + + JaroMetric.compare("martha", "marhta").get should be (0.9444444f) + JaroMetric.compare("dwayne", "duane").get should be (0.82222223f) + JaroMetric.compare("dixon", "dicksonx").get should be (0.76666665f) + JaroMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333f) + JaroMetric.compare("jones", "johnson").get should be (0.79047614f) + JaroMetric.compare("henka", "henkan").get should be (0.9444444f) + JaroMetric.compare("fvie", "ten").get should be (0.0f) + + JaroMetric.compare("zac ephron", "zac efron").get should be > + JaroMetric.compare("zac ephron", "kai ephron").get + JaroMetric.compare("brittney spears", "britney spears").get should be > + JaroMetric.compare("brittney spears", "brittney startzman").get + + JaroMetric.compare("m a r t h a", "m a r h t a").get should be (0.9444444f) + JaroMetric.compare("d w a y n e", "d u a n e").get should be (0.82222223f) + JaroMetric.compare("d i x o n", "d i c k s o n x").get should be (0.76666665f) + JaroMetric.compare("a b c v w x y z", "c a b v w x y z").get should be (0.9583333f) + JaroMetric.compare("j o n e s", "j o h n s o n").get should be (0.79047614f) + JaroMetric.compare("h e n k a", "h e n k a n").get should be (0.9444444f) + JaroMetric.compare("f v i e", "t e n").get should be (0.0f) + + JaroMetric.compare("z a c e p h r o n", "z a c e f r o n").get should be > + JaroMetric.compare("z a c e p h r o n", "k a i e p h r o n").get + JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s").get should be > + JaroMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n").get } } } diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala index 6e044a0..a7dfb72 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala @@ -9,44 +9,44 @@ final class JaroWinklerMetricSpec extends ScalaTest { "compare method" when passed { "valid arguments" should returns { "Float indicating distance" in { - JaroWinklerMetric.compare("abc", "abc") should be (1.0f) - JaroWinklerMetric.compare("abc", "xyz") should be (0.0f) - JaroWinklerMetric.compare("abc", "") should be (0.0f) - JaroWinklerMetric.compare("", "xyz") should be (0.0f) - JaroWinklerMetric.compare("", "") should be (0.0f) - JaroWinklerMetric.compare("a", "a") should be (1.0f) - - JaroWinklerMetric.compare("aa", "a") should be (0.84999996f) - JaroWinklerMetric.compare("a", "aa") should be (0.84999996f) - - JaroWinklerMetric.compare("veryveryverylong", "v") should be (0.71875f) - JaroWinklerMetric.compare("v", "veryveryverylong") should be (0.71875f) - - JaroWinklerMetric.compare("martha", "marhta") should be (0.96111107f) - JaroWinklerMetric.compare("dwayne", "duane") should be (0.84000003f) - JaroWinklerMetric.compare("dixon", "dicksonx") should be (0.81333333f) - JaroWinklerMetric.compare("abcvwxyz", "cabvwxyz") should be (0.9583333f) - JaroWinklerMetric.compare("jones", "johnson") should be (0.8323809f) - JaroWinklerMetric.compare("henka", "henkan") should be (0.96666664f) - JaroWinklerMetric.compare("fvie", "ten") should be (0.0f) - - JaroWinklerMetric.compare("zac ephron", "zac efron") should be > - JaroWinklerMetric.compare("zac ephron", "kai ephron") - JaroWinklerMetric.compare("brittney spears", "britney spears") should be > - JaroWinklerMetric.compare("brittney spears", "brittney startzman") - - JaroWinklerMetric.compare("m a r t h a", "m a r h t a") should be (0.96111107f) - JaroWinklerMetric.compare("d w a y n e", "d u a n e") should be (0.84000003f) - JaroWinklerMetric.compare("d i x o n", "d i c k s o n x") should be (0.81333333f) - JaroWinklerMetric.compare("a b c v w x y z", "c a b v w x y z") should be (0.9583333f) - JaroWinklerMetric.compare("j o n e s", "j o h n s o n") should be (0.8323809f) - JaroWinklerMetric.compare("h e n k a", "h e n k a n") should be (0.96666664f) - JaroWinklerMetric.compare("f v i e", "t e n") should be (0.0f) - - JaroWinklerMetric.compare("z a c e p h r o n", "z a c e f r o n") should be > - JaroWinklerMetric.compare("z a c e p h r o n", "k a i e p h r o n") - JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s") should be > - JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n") + JaroWinklerMetric.compare("abc", "abc").get should be (1.0f) + JaroWinklerMetric.compare("abc", "xyz").get should be (0.0f) + JaroWinklerMetric.compare("abc", "").isDefined should be (false) + JaroWinklerMetric.compare("", "xyz").isDefined should be (false) + JaroWinklerMetric.compare("", "").isDefined should be (false) + JaroWinklerMetric.compare("a", "a").get should be (1.0f) + + JaroWinklerMetric.compare("aa", "a").get should be (0.84999996f) + JaroWinklerMetric.compare("a", "aa").get should be (0.84999996f) + + JaroWinklerMetric.compare("veryveryverylong", "v").get should be (0.71875f) + JaroWinklerMetric.compare("v", "veryveryverylong").get should be (0.71875f) + + JaroWinklerMetric.compare("martha", "marhta").get should be (0.96111107f) + JaroWinklerMetric.compare("dwayne", "duane").get should be (0.84000003f) + JaroWinklerMetric.compare("dixon", "dicksonx").get should be (0.81333333f) + JaroWinklerMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333f) + JaroWinklerMetric.compare("jones", "johnson").get should be (0.8323809f) + JaroWinklerMetric.compare("henka", "henkan").get should be (0.96666664f) + JaroWinklerMetric.compare("fvie", "ten").get should be (0.0f) + + JaroWinklerMetric.compare("zac ephron", "zac efron").get should be > + JaroWinklerMetric.compare("zac ephron", "kai ephron").get + JaroWinklerMetric.compare("brittney spears", "britney spears").get should be > + JaroWinklerMetric.compare("brittney spears", "brittney startzman").get + + JaroWinklerMetric.compare("m a r t h a", "m a r h t a").get should be (0.96111107f) + JaroWinklerMetric.compare("d w a y n e", "d u a n e").get should be (0.84000003f) + JaroWinklerMetric.compare("d i x o n", "d i c k s o n x").get should be (0.81333333f) + JaroWinklerMetric.compare("a b c v w x y z", "c a b v w x y z").get should be (0.9583333f) + JaroWinklerMetric.compare("j o n e s", "j o h n s o n").get should be (0.8323809f) + JaroWinklerMetric.compare("h e n k a", "h e n k a n").get should be (0.96666664f) + JaroWinklerMetric.compare("f v i e", "t e n").get should be (0.0f) + + JaroWinklerMetric.compare("z a c e p h r o n", "z a c e f r o n").get should be > + JaroWinklerMetric.compare("z a c e p h r o n", "k a i e p h r o n").get + JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t n e y s p e a r s").get should be > + JaroWinklerMetric.compare("b r i t t n e y s p e a r s", "b r i t t n e y s t a r t z m a n").get } } } diff --git a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala index c688f9d..6e7b6d9 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala @@ -9,25 +9,25 @@ final class SoundexMetricSpec extends ScalaTest { "compare method" when passed { "valid arguments" should returns { "Boolean indicating matches" in { - SoundexMetric.compare("abc", "abc") should be (true) // a120 vs. a120 - SoundexMetric.compare("a", "a") should be (true) // a000 vs. a000 - SoundexMetric.compare("abc", "xyz") should be (false) // a120 vs. x200 - SoundexMetric.compare("", "") should be (false) - SoundexMetric.compare("123", "123") should be (false) - SoundexMetric.compare("1", "1") should be (false) + SoundexMetric.compare("abc", "abc").get should be (true) // a120 vs. a120 + SoundexMetric.compare("a", "a").get should be (true) // a000 vs. a000 + SoundexMetric.compare("abc", "xyz").get should be (false) // a120 vs. x200 + SoundexMetric.compare("", "").isDefined should be (false) + SoundexMetric.compare("123", "123").isDefined should be (false) + SoundexMetric.compare("1", "1").isDefined should be (false) - SoundexMetric.compare("Robert", "Rupert") should be (true) // r163 vs. r163 - SoundexMetric.compare("Robert", "Rubin") should be (false) // r163 vs. r150 + SoundexMetric.compare("Robert", "Rupert").get should be (true) // r163 vs. r163 + SoundexMetric.compare("Robert", "Rubin").get should be (false) // r163 vs. r150 - SoundexMetric.compare("Ashcraft", "Ashcroft") should be (true) // a261 vs. a261 - SoundexMetric.compare("Tymczak", "Tymczak") should be (true) // t522 vs. t522 - SoundexMetric.compare("Pfister", "Pfister") should be (true) // p236 vs. p236 - SoundexMetric.compare("Euler", "Ellery") should be (true) // e460 vs. e460 - SoundexMetric.compare("Gauss", "Ghosh") should be (true) // g200 vs. g200 - SoundexMetric.compare("Hilbert", "Heilbronn") should be (true) // h416 vs. h416 - SoundexMetric.compare("Knuth", "Kant") should be (true) // k530 vs. k530 - SoundexMetric.compare("Lloyd", "Ladd") should be (true) // l300 vs. l300 - SoundexMetric.compare("Lukasiewicz", "Lissajous") should be (true) // l222 vs. l222 + SoundexMetric.compare("Ashcraft", "Ashcroft").get should be (true) // a261 vs. a261 + SoundexMetric.compare("Tymczak", "Tymczak").get should be (true) // t522 vs. t522 + SoundexMetric.compare("Pfister", "Pfister").get should be (true) // p236 vs. p236 + SoundexMetric.compare("Euler", "Ellery").get should be (true) // e460 vs. e460 + SoundexMetric.compare("Gauss", "Ghosh").get should be (true) // g200 vs. g200 + SoundexMetric.compare("Hilbert", "Heilbronn").get should be (true) // h416 vs. h416 + SoundexMetric.compare("Knuth", "Kant").get should be (true) // k530 vs. k530 + SoundexMetric.compare("Lloyd", "Ladd").get should be (true) // l300 vs. l300 + SoundexMetric.compare("Lukasiewicz", "Lissajous").get should be (true) // l222 vs. l222 } } } |