From d88418dc98fafec114f7b608a8fe6323d5096479 Mon Sep 17 00:00:00 2001 From: Rocky Madden Date: Mon, 26 Nov 2012 15:36:27 -0700 Subject: More idiomatic code. --- .../hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala | 2 +- .../org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala | 2 +- .../org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala | 2 +- .../org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala | 2 +- .../stringmetric/cli/phonetic/refinedNysiisAlgorithm.scala | 2 +- .../hashtree/stringmetric/cli/phonetic/refinedNysiisMetric.scala | 2 +- .../stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala | 2 +- .../hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala | 2 +- .../org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala | 2 +- .../org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala | 2 +- .../hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala | 2 +- .../org/hashtree/stringmetric/cli/similarity/hammingMetric.scala | 2 +- .../org/hashtree/stringmetric/cli/similarity/jaroMetric.scala | 2 +- .../hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala | 2 +- .../hashtree/stringmetric/cli/similarity/levenshteinMetric.scala | 2 +- .../org/hashtree/stringmetric/cli/similarity/nGramAlgorithm.scala | 8 +++----- .../org/hashtree/stringmetric/cli/similarity/nGramMetric.scala | 2 +- .../stringmetric/cli/similarity/weightedLevenshteinMetric.scala | 2 +- 18 files changed, 20 insertions(+), 22 deletions(-) (limited to 'cli/source') diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala index 29095c0..c318a55 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneAlgorithm.scala @@ -45,6 +45,6 @@ object metaphoneAlgorithm extends Command { println( MetaphoneAlgorithm.compute( options('dashless) - ).getOrElse("not computable").toString + ).getOrElse("not computable") ) } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala index 24c58b4..22227dc 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/metaphoneMetric.scala @@ -48,7 +48,7 @@ object metaphoneMetric extends Command { MetaphoneMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala index 2cb2888..994ee1d 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisAlgorithm.scala @@ -45,6 +45,6 @@ object nysiisAlgorithm extends Command { println( NysiisAlgorithm.compute( options('dashless) - ).getOrElse("not computable").toString + ).getOrElse("not computable") ) } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala index cbac34d..2dca78e 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/nysiisMetric.scala @@ -48,7 +48,7 @@ object nysiisMetric extends Command { NysiisMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisAlgorithm.scala index 9953116..156fa07 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisAlgorithm.scala @@ -45,6 +45,6 @@ object refinedNysiisAlgorithm extends Command { println( RefinedNysiisAlgorithm.compute( options('dashless) - ).getOrElse("not computable").toString + ).getOrElse("not computable") ) } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisMetric.scala index b09075a..12e0ecd 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedNysiisMetric.scala @@ -48,7 +48,7 @@ object refinedNysiisMetric extends Command { RefinedNysiisMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala index 30da5d3..7071175 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexAlgorithm.scala @@ -45,6 +45,6 @@ object refinedSoundexAlgorithm extends Command { println( RefinedSoundexAlgorithm.compute( options('dashless) - ).getOrElse("not computable").toString + ).getOrElse("not computable") ) } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala index c2a1f67..950367e 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/refinedSoundexMetric.scala @@ -48,7 +48,7 @@ object refinedSoundexMetric extends Command { RefinedSoundexMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala index 4144800..63ae5cb 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexAlgorithm.scala @@ -45,6 +45,6 @@ object soundexAlgorithm extends Command { println( SoundexAlgorithm.compute( options('dashless) - ).getOrElse("not computable").toString + ).getOrElse("not computable") ) } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala index db9632d..4353be1 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/phonetic/soundexMetric.scala @@ -48,7 +48,7 @@ object soundexMetric extends Command { SoundexMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala index 5d6590c..395136b 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/diceSorensenMetric.scala @@ -53,7 +53,7 @@ object diceSorensenMetric extends Command { DiceSorensenMetric.compare( strings(0), strings(1) - )(n).getOrElse("not comparable").toString + )(n).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala index 77af8b5..4b12009 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/hammingMetric.scala @@ -48,7 +48,7 @@ object hammingMetric extends Command { HammingMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala index 43a05ac..3a81050 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroMetric.scala @@ -45,7 +45,7 @@ object jaroMetric extends Command { JaroMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala index 76549c0..f49596c 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/jaroWinklerMetric.scala @@ -48,7 +48,7 @@ object jaroWinklerMetric extends Command { JaroWinklerMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala index cfc193b..fde64fb 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/levenshteinMetric.scala @@ -49,7 +49,7 @@ object levenshteinMetric extends Command { LevenshteinMetric.compare( strings(0), strings(1) - ).getOrElse("not comparable").toString + ).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramAlgorithm.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramAlgorithm.scala index 555efbf..82da50f 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramAlgorithm.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramAlgorithm.scala @@ -46,11 +46,9 @@ object nGramAlgorithm extends Command { override def execute(options: OptionMap): Unit = { val n = ParseUtility.parseInt(options('n)).get - val ngram = NGramAlgorithm.compute(options('dashless))(n) - ngram match { - case Some(a) => println(a.mkString("|")) - case None => println("not computable") - } + println( + NGramAlgorithm.compute(options('dashless))(n).map(_.mkString("|")).getOrElse("not computable") + ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramMetric.scala index eeb574a..07e4db6 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/nGramMetric.scala @@ -53,7 +53,7 @@ object nGramMetric extends Command { NGramMetric.compare( strings(0), strings(1) - )(n).getOrElse("not comparable").toString + )(n).getOrElse("not comparable") ) } } \ No newline at end of file diff --git a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/weightedLevenshteinMetric.scala b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/weightedLevenshteinMetric.scala index 1e686f7..f6e4771 100755 --- a/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/weightedLevenshteinMetric.scala +++ b/cli/source/core/scala/org/hashtree/stringmetric/cli/similarity/weightedLevenshteinMetric.scala @@ -66,7 +66,7 @@ object weightedLevenshteinMetric extends Command { WeightedLevenshteinMetric.compare( strings(0), strings(1) - )(weights).getOrElse("not comparable").toString + )(weights).getOrElse("not comparable") ) } } \ No newline at end of file -- cgit v1.2.3