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 /cli | |
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.
Diffstat (limited to 'cli')
4 files changed, 10 insertions, 3 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 { |