From 315422887d00e333a9f113fc16089c4e8468ca61 Mon Sep 17 00:00:00 2001 From: Rocky Madden Date: Thu, 7 Mar 2013 11:05:07 -0700 Subject: Favored dependency injection. --- .../stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala | 4 ++-- .../stringmetric/phonetic/MetaphoneMetricBenchmark.scala | 4 ++-- .../stringmetric/phonetic/NysiisAlgorithmBenchmark.scala | 6 +++--- .../rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala | 4 ++-- .../stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala | 4 ++-- .../stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala | 4 ++-- .../stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala | 4 ++-- .../stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala | 4 ++-- .../stringmetric/phonetic/SoundexAlgorithmBenchmark.scala | 4 ++-- .../rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/DiceSorensenMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/HammingMetricBenchmark.scala | 4 ++-- .../rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/JaroWinklerMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/LevenshteinMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/NGramAlgorithmBenchmark.scala | 4 ++-- .../rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala | 4 ++-- .../stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala | 4 ++-- .../similarity/WeightedLevenshteinMetricBenchmark.scala | 4 ++-- .../com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala | 6 +----- .../com/rockymadden/stringmetric/ConfigurableStringMetric.scala | 6 +----- core/source/core/scala/com/rockymadden/stringmetric/Filter.scala | 4 +++- .../core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala | 6 +----- .../core/scala/com/rockymadden/stringmetric/StringFilter.scala | 4 +++- .../core/scala/com/rockymadden/stringmetric/StringMetric.scala | 6 +----- .../com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithm.scala | 6 ++++-- .../com/rockymadden/stringmetric/phonetic/MetaphoneMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/phonetic/NysiisAlgorithm.scala | 6 ++++-- .../scala/com/rockymadden/stringmetric/phonetic/NysiisMetric.scala | 6 ++++-- .../rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithm.scala | 6 ++++-- .../com/rockymadden/stringmetric/phonetic/RefinedNysiisMetric.scala | 6 ++++-- .../rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithm.scala | 6 ++++-- .../rockymadden/stringmetric/phonetic/RefinedSoundexMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/phonetic/SoundexAlgorithm.scala | 6 ++++-- .../scala/com/rockymadden/stringmetric/phonetic/SoundexMetric.scala | 6 ++++-- .../rockymadden/stringmetric/similarity/DiceSorensenMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/similarity/HammingMetric.scala | 6 ++++-- .../scala/com/rockymadden/stringmetric/similarity/JaroMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/similarity/JaroWinklerMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala | 6 ++++-- .../com/rockymadden/stringmetric/similarity/NGramAlgorithm.scala | 6 ++++-- .../scala/com/rockymadden/stringmetric/similarity/NGramMetric.scala | 6 ++++-- .../stringmetric/similarity/RatcliffObershelpMetric.scala | 6 ++++-- .../stringmetric/similarity/WeightedLevenshteinMetric.scala | 6 ++++-- .../scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala | 2 +- .../rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala | 4 ++-- .../stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala | 4 ++-- .../rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala | 4 ++-- .../stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala | 4 ++-- .../stringmetric/phonetic/RefinedSoundexMetricSpec.scala | 4 ++-- .../rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala | 4 ++-- .../stringmetric/similarity/DiceSorensenMetricSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala | 4 ++-- .../rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala | 4 ++-- .../rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala | 4 ++-- .../rockymadden/stringmetric/similarity/NGramAlgorithmSpec.scala | 4 ++-- .../com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala | 4 ++-- .../stringmetric/similarity/RatcliffObershelpMetricSpec.scala | 4 ++-- .../stringmetric/similarity/WeightedLevenshteinMetricSpec.scala | 4 ++-- 64 files changed, 164 insertions(+), 138 deletions(-) (limited to 'core') diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala index c8c22e8..7af1a2c 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmBenchmark.scala @@ -5,7 +5,7 @@ import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } import scala.util.Random final class MetaphoneAlgorithmBenchmark extends CaliperBenchmark { - import MetaphoneAlgorithmBenchmark._ + import MetaphoneAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -28,5 +28,5 @@ final class MetaphoneAlgorithmBenchmark extends CaliperBenchmark { } object MetaphoneAlgorithmBenchmark extends CaliperRunner(classOf[MetaphoneAlgorithmBenchmark]) { - private final val Algorithm = new MetaphoneAlgorithm + private final val Algorithm = MetaphoneAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala index 73a9b4f..34e77b3 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class MetaphoneMetricBenchmark extends CaliperBenchmark { - import MetaphoneMetricBenchmark._ + import MetaphoneMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class MetaphoneMetricBenchmark extends CaliperBenchmark { } object MetaphoneMetricBenchmark extends CaliperRunner(classOf[MetaphoneMetricBenchmark]) { - private final val Metric = new MetaphoneMetric + private final val Metric = MetaphoneMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala index 9680c77..97f88ed 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmBenchmark.scala @@ -1,11 +1,11 @@ package com.rockymadden.stringmetric.phonetic import com.google.caliper.Param -import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } +import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner, StringFilter } import scala.util.Random final class NysiisAlgorithmBenchmark extends CaliperBenchmark { - import NysiisAlgorithmBenchmark._ + import NysiisAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -28,5 +28,5 @@ final class NysiisAlgorithmBenchmark extends CaliperBenchmark { } object NysiisAlgorithmBenchmark extends CaliperRunner(classOf[NysiisAlgorithmBenchmark]) { - private final val Algorithm = new NysiisAlgorithm + private final val Algorithm = NysiisAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala index 5be6ef8..0af61c1 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class NysiisMetricBenchmark extends CaliperBenchmark { - import NysiisMetricBenchmark._ + import NysiisMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class NysiisMetricBenchmark extends CaliperBenchmark { } object NysiisMetricBenchmark extends CaliperRunner(classOf[NysiisMetricBenchmark]) { - private final val Metric = new NysiisMetric + private final val Metric = NysiisMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala index 95fd775..65d9d8f 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmBenchmark.scala @@ -5,7 +5,7 @@ import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } import scala.util.Random final class RefinedNysiisAlgorithmBenchmark extends CaliperBenchmark { - import RefinedNysiisAlgorithmBenchmark._ + import RefinedNysiisAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -28,5 +28,5 @@ final class RefinedNysiisAlgorithmBenchmark extends CaliperBenchmark { } object RefinedNysiisAlgorithmBenchmark extends CaliperRunner(classOf[RefinedNysiisAlgorithmBenchmark]) { - private final val Algorithm = new RefinedNysiisAlgorithm + private final val Algorithm = RefinedNysiisAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala index 8a9e208..b7d8c93 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class RefinedNysiisMetricBenchmark extends CaliperBenchmark { - import RefinedNysiisMetricBenchmark._ + import RefinedNysiisMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class RefinedNysiisMetricBenchmark extends CaliperBenchmark { } object RefinedNysiisMetricBenchmark extends CaliperRunner(classOf[RefinedNysiisMetricBenchmark]) { - private final val Metric = new RefinedNysiisMetric + private final val Metric = RefinedNysiisMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala index cbb5d10..e2f58d3 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmBenchmark.scala @@ -5,7 +5,7 @@ import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } import scala.util.Random final class RefinedSoundexAlgorithmBenchmark extends CaliperBenchmark { - import RefinedSoundexAlgorithmBenchmark._ + import RefinedSoundexAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -28,5 +28,5 @@ final class RefinedSoundexAlgorithmBenchmark extends CaliperBenchmark { } object RefinedSoundexAlgorithmBenchmark extends CaliperRunner(classOf[RefinedSoundexAlgorithmBenchmark]) { - private final val Algorithm = new RefinedSoundexAlgorithm + private final val Algorithm = RefinedSoundexAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala index 9ccaf95..71a2485 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class RefinedSoundexMetricBenchmark extends CaliperBenchmark { - import RefinedSoundexMetricBenchmark._ + import RefinedSoundexMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class RefinedSoundexMetricBenchmark extends CaliperBenchmark { } object RefinedSoundexMetricBenchmark extends CaliperRunner(classOf[RefinedSoundexMetricBenchmark]) { - private final val Metric = new RefinedSoundexMetric + private final val Metric = RefinedSoundexMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala index 91dad8f..8f5fd83 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmBenchmark.scala @@ -5,7 +5,7 @@ import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } import scala.util.Random final class SoundexAlgorithmBenchmark extends CaliperBenchmark { - import SoundexAlgorithmBenchmark._ + import SoundexAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -28,5 +28,5 @@ final class SoundexAlgorithmBenchmark extends CaliperBenchmark { } object SoundexAlgorithmBenchmark extends CaliperRunner(classOf[SoundexAlgorithmBenchmark]) { - private final val Algorithm = new SoundexAlgorithm + private final val Algorithm = SoundexAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala index df2828f..7d20a24 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class SoundexMetricBenchmark extends CaliperBenchmark { - import SoundexMetricBenchmark._ + import SoundexMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class SoundexMetricBenchmark extends CaliperBenchmark { } object SoundexMetricBenchmark extends CaliperRunner(classOf[SoundexMetricBenchmark]) { - private final val Metric = new SoundexMetric + private final val Metric = SoundexMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala index 8f4a90e..6561b97 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class DiceSorensenMetricBenchmark extends CaliperBenchmark { - import DiceSorensenMetricBenchmark._ + import DiceSorensenMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class DiceSorensenMetricBenchmark extends CaliperBenchmark { } object DiceSorensenMetricBenchmark extends CaliperRunner(classOf[DiceSorensenMetricBenchmark]) { - private final val Metric = new DiceSorensenMetric + private final val Metric = DiceSorensenMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala index 660ac88..1e9b7db 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/HammingMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class HammingMetricBenchmark extends CaliperBenchmark { - import HammingMetricBenchmark._ + import HammingMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class HammingMetricBenchmark extends CaliperBenchmark { } object HammingMetricBenchmark extends CaliperRunner(classOf[HammingMetricBenchmark]) { - private final val Metric = new HammingMetric + private final val Metric = HammingMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala index b2da3dc..d43d594 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class JaroMetricBenchmark extends CaliperBenchmark { - import JaroMetricBenchmark._ + import JaroMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class JaroMetricBenchmark extends CaliperBenchmark { } object JaroMetricBenchmark extends CaliperRunner(classOf[JaroMetricBenchmark]) { - private final val Metric = new JaroMetric + private final val Metric = JaroMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala index e85597a..dab240a 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class JaroWinklerMetricBenchmark extends CaliperBenchmark { - import JaroWinklerMetricBenchmark._ + import JaroWinklerMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class JaroWinklerMetricBenchmark extends CaliperBenchmark { } object JaroWinklerMetricBenchmark extends CaliperRunner(classOf[JaroWinklerMetricBenchmark]) { - private final val Metric = new JaroWinklerMetric + private final val Metric = JaroWinklerMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala index 01c6a6c..3f0fe55 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class LevenshteinMetricBenchmark extends CaliperBenchmark { - import LevenshteinMetricBenchmark._ + import LevenshteinMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class LevenshteinMetricBenchmark extends CaliperBenchmark { } object LevenshteinMetricBenchmark extends CaliperRunner(classOf[LevenshteinMetricBenchmark]) { - private final val Metric = new LevenshteinMetric + private final val Metric = LevenshteinMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmBenchmark.scala index 0b8f718..ae34220 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmBenchmark.scala @@ -5,7 +5,7 @@ import com.rockymadden.stringmetric.{ CaliperBenchmark, CaliperRunner } import scala.util.Random final class NGramAlgorithmBenchmark extends CaliperBenchmark { - import NGramAlgorithmBenchmark._ + import NGramAlgorithmBenchmark.Algorithm @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -31,5 +31,5 @@ final class NGramAlgorithmBenchmark extends CaliperBenchmark { } object NGramAlgorithmBenchmark extends CaliperRunner(classOf[NGramAlgorithmBenchmark]) { - private final val Algorithm = new NGramAlgorithm + private final val Algorithm = NGramAlgorithm() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala index 4829b22..1ded58b 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/NGramMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class NGramMetricBenchmark extends CaliperBenchmark { - import NGramMetricBenchmark._ + import NGramMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -54,5 +54,5 @@ final class NGramMetricBenchmark extends CaliperBenchmark { } object NGramMetricBenchmark extends CaliperRunner(classOf[NGramMetricBenchmark]) { - private final val Metric = new NGramMetric + private final val Metric = NGramMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala index 6050cc7..f89ba22 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class RatcliffObershelpMetricBenchmark extends CaliperBenchmark { - import RatcliffObershelpMetricBenchmark._ + import RatcliffObershelpMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class RatcliffObershelpMetricBenchmark extends CaliperBenchmark { } object RatcliffObershelpMetricBenchmark extends CaliperRunner(classOf[RatcliffObershelpMetricBenchmark]) { - private final val Metric = new RatcliffObershelpMetric + private final val Metric = RatcliffObershelpMetric() } diff --git a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala index a5424a2..35726bf 100755 --- a/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala +++ b/core/source/benchmark/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricBenchmark.scala @@ -6,7 +6,7 @@ import scala.annotation.tailrec import scala.util.Random final class WeightedLevenshteinMetricBenchmark extends CaliperBenchmark { - import WeightedLevenshteinMetricBenchmark._ + import WeightedLevenshteinMetricBenchmark.Metric @Param(Array("0", "1", "2", "4", "8", "16")) var length: Int = _ @@ -51,5 +51,5 @@ final class WeightedLevenshteinMetricBenchmark extends CaliperBenchmark { } object WeightedLevenshteinMetricBenchmark extends CaliperRunner(classOf[WeightedLevenshteinMetricBenchmark]) { - private final val Metric = new WeightedLevenshteinMetric + private final val Metric = WeightedLevenshteinMetric() } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala index 8cef966..33fd61e 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala @@ -2,12 +2,8 @@ package com.rockymadden.stringmetric import com.rockymadden.stringmetric.similarity.NGramAlgorithm -trait ConfigurableStringAlgorithm[R, O] extends ConfigurableAlgorithm[String, R, O] with StringFilterable { +trait ConfigurableStringAlgorithm[R, O] extends ConfigurableAlgorithm[String, R, O] { def compute(charArray: Array[Char])(implicit o: O): Option[Array[_]] - - override def filter(charArray: Array[Char]): Array[Char] = charArray - - override def filter(string: String): String = string } object ConfigurableStringAlgorithm { diff --git a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala index da3e333..80f3e49 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala @@ -2,12 +2,8 @@ package com.rockymadden.stringmetric import com.rockymadden.stringmetric.similarity.{ DiceSorensenMetric, NGramMetric, WeightedLevenshteinMetric } -trait ConfigurableStringMetric[R, O] extends ConfigurableMetric[String, R, O] with StringFilterable { +trait ConfigurableStringMetric[R, O] extends ConfigurableMetric[String, R, O] { def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit o: O): Option[R] - - override def filter(charArray: Array[Char]): Array[Char] = charArray - - override def filter(string: String): String = string } object ConfigurableStringMetric { diff --git a/core/source/core/scala/com/rockymadden/stringmetric/Filter.scala b/core/source/core/scala/com/rockymadden/stringmetric/Filter.scala index 860c9e3..b651c30 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/Filter.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/Filter.scala @@ -1,3 +1,5 @@ package com.rockymadden.stringmetric -trait Filter[T] extends Filterable[T] +trait Filter[T] extends Filterable[T] { + override def filter(t: T): T = t +} diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala index 87d0dc6..2d72e60 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala @@ -2,12 +2,8 @@ package com.rockymadden.stringmetric import com.rockymadden.stringmetric.phonetic.{ MetaphoneAlgorithm, NysiisAlgorithm, RefinedSoundexAlgorithm, SoundexAlgorithm } -trait StringAlgorithm[R] extends Algorithm[String, R] with StringFilterable { +trait StringAlgorithm[R] extends Algorithm[String, R] { def compute(charArray: Array[Char]): Option[Array[_]] - - override def filter(charArray: Array[Char]): Array[Char] = charArray - - override def filter(string: String): String = string } object StringAlgorithm { diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala index e362b2f..88c58c2 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala @@ -2,7 +2,9 @@ package com.rockymadden.stringmetric import com.rockymadden.stringmetric.filter._ -trait StringFilter extends Filter[String] with StringFilterable +trait StringFilter extends Filter[String] with StringFilterable { + override def filter(charArray: Array[Char]): Array[Char] = charArray +} object StringFilter { def asciiControl = new StringFilterDelegate with AsciiControlStringFilter diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala index 6905ec3..418ec8b 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala @@ -3,12 +3,8 @@ package com.rockymadden.stringmetric import com.rockymadden.stringmetric.phonetic.{ MetaphoneMetric, NysiisMetric, RefinedSoundexMetric, SoundexMetric } import com.rockymadden.stringmetric.similarity._ -trait StringMetric[R] extends Metric[String, R] with StringFilterable { +trait StringMetric[R] extends Metric[String, R] { def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[R] - - override def filter(charArray: Array[Char]): Array[Char] = charArray - - override def filter(string: String): String = string } object StringMetric { diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithm.scala index cb1bb45..1949375 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringAlgorithm +import com.rockymadden.stringmetric.{ StringAlgorithm, StringFilter } import scala.annotation.{ switch, tailrec } /** An implementation of the Metaphone algorithm. */ class MetaphoneAlgorithm extends StringAlgorithm[String] { + this: StringFilter => + final override def compute(charArray: Array[Char]): Option[Array[Char]] = { val fca = filter(charArray) @@ -112,5 +114,5 @@ class MetaphoneAlgorithm extends StringAlgorithm[String] { } object MetaphoneAlgorithm { - def apply(): MetaphoneAlgorithm = new MetaphoneAlgorithm + def apply(): MetaphoneAlgorithm = new MetaphoneAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetric.scala index 5c76262..a694d5f 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** A implementation of the Metaphone metric. */ class MetaphoneMetric extends StringMetric[Boolean] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -22,5 +24,5 @@ class MetaphoneMetric extends StringMetric[Boolean] { } object MetaphoneMetric { - def apply(): MetaphoneMetric = new MetaphoneMetric + def apply(): MetaphoneMetric = new MetaphoneMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithm.scala index a83b563..3f2d029 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringAlgorithm +import com.rockymadden.stringmetric.{ StringAlgorithm, StringFilter } import scala.annotation.{ switch, tailrec } /** An implementation of the NYSIIS algorithm. */ class NysiisAlgorithm extends StringAlgorithm[String] { + this: StringFilter => + final override def compute(charArray: Array[Char]): Option[Array[Char]] = { val fca = filter(charArray) @@ -119,5 +121,5 @@ class NysiisAlgorithm extends StringAlgorithm[String] { } object NysiisAlgorithm { - def apply(): NysiisAlgorithm = new NysiisAlgorithm + def apply(): NysiisAlgorithm = new NysiisAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisMetric.scala index ab9527b..6560ad7 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/NysiisMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** An implementation of the NYSIIS metric. */ class NysiisMetric extends StringMetric[Boolean] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = { val unequal = (c1: Char, c2: Char) => { val lc1 = c1.toLower @@ -30,5 +32,5 @@ class NysiisMetric extends StringMetric[Boolean] { } object NysiisMetric { - def apply(): NysiisMetric = new NysiisMetric + def apply(): NysiisMetric = new NysiisMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithm.scala index 32f05d0..e779296 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringAlgorithm +import com.rockymadden.stringmetric.{ StringAlgorithm, StringFilter } import scala.annotation.{ switch, tailrec } /** An implementation of the refined NYSIIS algorithm. */ class RefinedNysiisAlgorithm extends StringAlgorithm[String] { + this: StringFilter => + final override def compute(charArray: Array[Char]): Option[Array[Char]] = { val fca = filter(charArray) @@ -123,5 +125,5 @@ class RefinedNysiisAlgorithm extends StringAlgorithm[String] { } object RefinedNysiisAlgorithm { - def apply(): RefinedNysiisAlgorithm = new RefinedNysiisAlgorithm + def apply(): RefinedNysiisAlgorithm = new RefinedNysiisAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetric.scala index 0db8a8c..16ac11a 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** An implementation of the refined NYSIIS metric. */ class RefinedNysiisMetric extends StringMetric[Boolean] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = { val unequal = (c1: Char, c2: Char) => { val lc1 = c1.toLower @@ -30,5 +32,5 @@ class RefinedNysiisMetric extends StringMetric[Boolean] { } object RefinedNysiisMetric { - def apply(): RefinedNysiisMetric = new RefinedNysiisMetric + def apply(): RefinedNysiisMetric = new RefinedNysiisMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithm.scala index b054a99..cda0e7e 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringAlgorithm +import com.rockymadden.stringmetric.{ StringAlgorithm, StringFilter } import scala.annotation.{ switch, tailrec } /** An implementation of the refined Soundex algorithm. */ class RefinedSoundexAlgorithm extends StringAlgorithm[String] { + this: StringFilter => + final override def compute(charArray: Array[Char]): Option[Array[Char]] = { val fca = filter(charArray) @@ -63,5 +65,5 @@ class RefinedSoundexAlgorithm extends StringAlgorithm[String] { } object RefinedSoundexAlgorithm { - def apply(): RefinedSoundexAlgorithm = new RefinedSoundexAlgorithm + def apply(): RefinedSoundexAlgorithm = new RefinedSoundexAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetric.scala index 5ad134e..3e78e34 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** An implementation of the refined Soundex metric. */ class RefinedSoundexMetric extends StringMetric[Boolean] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -23,5 +25,5 @@ class RefinedSoundexMetric extends StringMetric[Boolean] { } object RefinedSoundexMetric { - def apply(): RefinedSoundexMetric = new RefinedSoundexMetric + def apply(): RefinedSoundexMetric = new RefinedSoundexMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithm.scala index 0ab4a5b..04f5525 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringAlgorithm +import com.rockymadden.stringmetric.{ StringAlgorithm, StringFilter } import scala.annotation.{ switch, tailrec } /** An implementation of the Soundex algorithm. */ class SoundexAlgorithm extends StringAlgorithm[String] { + this: StringFilter => + final override def compute(charArray: Array[Char]): Option[Array[Char]] = { val fca = filter(charArray) @@ -61,5 +63,5 @@ class SoundexAlgorithm extends StringAlgorithm[String] { } object SoundexAlgorithm { - def apply(): SoundexAlgorithm = new SoundexAlgorithm + def apply(): SoundexAlgorithm = new SoundexAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexMetric.scala index bb011be..a9d7784 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/phonetic/SoundexMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.phonetic -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** An implementation of the Soundex metric. */ class SoundexMetric extends StringMetric[Boolean] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -23,5 +25,5 @@ class SoundexMetric extends StringMetric[Boolean] { } object SoundexMetric { - def apply(): SoundexMetric = new SoundexMetric + def apply(): SoundexMetric = new SoundexMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala index 9e3e968..8250cf3 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala @@ -1,12 +1,14 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ ConfigurableStringMetric, MatchTuple } +import com.rockymadden.stringmetric.{ ConfigurableStringMetric, MatchTuple, StringFilter } /** * An implementation of the Dice/Sorensen metric. This implementation differs in that n-gram size is required. * Traditionally, the algorithm uses bigrams. */ class DiceSorensenMetric extends ConfigurableStringMetric[Double, Int] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit n: Int): Option[Double] = { if (n <= 0) throw new IllegalArgumentException("Expected valid n.") @@ -35,5 +37,5 @@ class DiceSorensenMetric extends ConfigurableStringMetric[Double, Int] { } object DiceSorensenMetric { - def apply(): DiceSorensenMetric = new DiceSorensenMetric + def apply(): DiceSorensenMetric = new DiceSorensenMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/HammingMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/HammingMetric.scala index 8256929..37cc6a1 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/HammingMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/HammingMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ CompareTuple, StringMetric } +import com.rockymadden.stringmetric.{ CompareTuple, StringFilter, StringMetric } /** An implementation of the Hamming metric. */ class HammingMetric extends StringMetric[Int] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Int] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -25,5 +27,5 @@ class HammingMetric extends StringMetric[Int] { } object HammingMetric { - def apply(): HammingMetric = new HammingMetric + def apply(): HammingMetric = new HammingMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroMetric.scala index c44fde2..8e3d5d7 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroMetric.scala @@ -1,6 +1,6 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ CompareTuple, MatchTuple, StringMetric } +import com.rockymadden.stringmetric.{ CompareTuple, MatchTuple, StringFilter, StringMetric } import scala.collection.mutable.{ ArrayBuffer, HashSet } /** @@ -8,6 +8,8 @@ import scala.collection.mutable.{ ArrayBuffer, HashSet } * in string2, it cannot be matched upon again. This results in a more penalized distance in these scenarios. */ class JaroMetric extends StringMetric[Double] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -75,5 +77,5 @@ class JaroMetric extends StringMetric[Double] { } object JaroMetric { - def apply(): JaroMetric = new JaroMetric + def apply(): JaroMetric = new JaroMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetric.scala index baa9bf1..70ffa17 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetric.scala @@ -1,6 +1,6 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.StringMetric +import com.rockymadden.stringmetric.{ StringFilter, StringMetric } /** * An implementation of the Jaro-Winkler metric. One differing detail in this implementation is that if a character is @@ -8,6 +8,8 @@ import com.rockymadden.stringmetric.StringMetric * (e.g. comparing henka and henkan distance is 0.9666 versus the typical 0.9722). */ class JaroWinklerMetric extends StringMetric[Double] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = { val fca1 = filter(charArray1) val fca2 = filter(charArray2) @@ -28,5 +30,5 @@ class JaroWinklerMetric extends StringMetric[Double] { } object JaroWinklerMetric { - def apply(): JaroWinklerMetric = new JaroWinklerMetric + def apply(): JaroWinklerMetric = new JaroWinklerMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala index 7dd1643..440ca48 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ CompareTuple, StringMetric } +import com.rockymadden.stringmetric.{ CompareTuple, StringFilter, StringMetric } /** An implementation of the Levenshtein metric. */ class LevenshteinMetric extends StringMetric[Int] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Int] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -47,5 +49,5 @@ class LevenshteinMetric extends StringMetric[Int] { } object LevenshteinMetric { - def apply(): LevenshteinMetric = new LevenshteinMetric + def apply(): LevenshteinMetric = new LevenshteinMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithm.scala index b50ed7d..0b95c75 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithm.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.ConfigurableStringAlgorithm +import com.rockymadden.stringmetric.{ ConfigurableStringAlgorithm, StringFilter } import scala.annotation.tailrec /** An implementation of the N-Gram algorithm. */ class NGramAlgorithm extends ConfigurableStringAlgorithm[Array[String], Int] { + this: StringFilter => + final override def compute(charArray: Array[Char])(implicit n: Int): Option[Array[Array[Char]]] = { if (n <= 0) throw new IllegalArgumentException("Expected valid n.") @@ -27,5 +29,5 @@ class NGramAlgorithm extends ConfigurableStringAlgorithm[Array[String], Int] { } object NGramAlgorithm { - def apply(): NGramAlgorithm = new NGramAlgorithm + def apply(): NGramAlgorithm = new NGramAlgorithm with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramMetric.scala index c621765..56c9c88 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/NGramMetric.scala @@ -1,10 +1,12 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ ConfigurableStringMetric, MatchTuple } +import com.rockymadden.stringmetric.{ ConfigurableStringMetric, MatchTuple, StringFilter } import scala.math /** An implementation of the N-Gram metric. */ class NGramMetric extends ConfigurableStringMetric[Double, Int] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit n: Int): Option[Double] = { if (n <= 0) throw new IllegalArgumentException("Expected valid n.") @@ -33,5 +35,5 @@ class NGramMetric extends ConfigurableStringMetric[Double, Int] { } object NGramMetric { - def apply(): NGramMetric = new NGramMetric + def apply(): NGramMetric = new NGramMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetric.scala index 7d2ef10..415641d 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetric.scala @@ -1,9 +1,11 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ CompareTuple, StringMetric } +import com.rockymadden.stringmetric.{ CompareTuple, StringFilter, StringMetric } /** An implementation of the Ratcliff/Obershelp metric. */ class RatcliffObershelpMetric extends StringMetric[Double] { + this: StringFilter => + final override def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = { val fca1 = filter(charArray1) lazy val fca2 = filter(charArray2) @@ -45,5 +47,5 @@ class RatcliffObershelpMetric extends StringMetric[Double] { } object RatcliffObershelpMetric { - def apply(): RatcliffObershelpMetric = new RatcliffObershelpMetric + def apply(): RatcliffObershelpMetric = new RatcliffObershelpMetric with StringFilter } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala index cbc9fe5..6aafbcd 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala @@ -1,12 +1,14 @@ package com.rockymadden.stringmetric.similarity -import com.rockymadden.stringmetric.{ CompareTuple, ConfigurableStringMetric } +import com.rockymadden.stringmetric.{ CompareTuple, ConfigurableStringMetric, StringFilter } import scala.math.BigDecimal /** An implementation of a weighted Levenshtein metric. */ class WeightedLevenshteinMetric extends ConfigurableStringMetric[Double, (BigDecimal, BigDecimal, BigDecimal)] { + this: StringFilter => + /** Options order is delete, insert, then substitute weight. */ final override def compare(charArray1: Array[Char], charArray2: Array[Char]) (implicit options: (BigDecimal, BigDecimal, BigDecimal)): Option[Double] = { @@ -50,5 +52,5 @@ class WeightedLevenshteinMetric } object WeightedLevenshteinMetric { - def apply(): WeightedLevenshteinMetric = new WeightedLevenshteinMetric + def apply(): WeightedLevenshteinMetric = new WeightedLevenshteinMetric with StringFilter } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala index 1cca109..92f4578 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala @@ -8,7 +8,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class FilterDecoratedSpec extends ScalaTest { - import FilterDecoratedSpec._ + import FilterDecoratedSpec.{ Algorithm, Metric } "Filter decorated metrics" should provide { "compare method" when passed { diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala index 288bd60..6698358 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class MetaphoneAlgorithmSpec extends ScalaTest { - import MetaphoneAlgorithmSpec._ + import MetaphoneAlgorithmSpec.Algorithm "MetaphoneAlgorithm" should provide { "compute method" when passed { @@ -215,5 +215,5 @@ final class MetaphoneAlgorithmSpec extends ScalaTest { } object MetaphoneAlgorithmSpec { - final private val Algorithm = new MetaphoneAlgorithm + final private val Algorithm = MetaphoneAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala index 36382ba..867e49b 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class MetaphoneMetricSpec extends ScalaTest { - import MetaphoneMetricSpec._ + import MetaphoneMetricSpec.Metric "MetaphoneMetric" should provide { "compare method" when passed { @@ -43,5 +43,5 @@ final class MetaphoneMetricSpec extends ScalaTest { } object MetaphoneMetricSpec { - final private val Metric = new MetaphoneMetric + final private val Metric = MetaphoneMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala index d6c15a8..69c23d9 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class NysiisAlgorithmSpec extends ScalaTest { - import NysiisAlgorithmSpec._ + import NysiisAlgorithmSpec.Algorithm "NysiisAlgorithm" should provide { "compute method" when passed { @@ -193,5 +193,5 @@ final class NysiisAlgorithmSpec extends ScalaTest { } object NysiisAlgorithmSpec { - final private val Algorithm = new NysiisAlgorithm + final private val Algorithm = NysiisAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala index a4ad219..92748e6 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class NysiisMetricSpec extends ScalaTest { - import NysiisMetricSpec._ + import NysiisMetricSpec.Metric "NysiisMetric" should provide { "compare method" when passed { @@ -39,5 +39,5 @@ final class NysiisMetricSpec extends ScalaTest { } object NysiisMetricSpec { - final private val Metric = new NysiisMetric + final private val Metric = NysiisMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala index d384149..bb5d99d 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class RefinedNysiisAlgorithmSpec extends ScalaTest { - import RefinedNysiisAlgorithmSpec._ + import RefinedNysiisAlgorithmSpec.Algorithm "RefinedNysiisAlgorithm" should provide { "compute method" when passed { @@ -210,5 +210,5 @@ final class RefinedNysiisAlgorithmSpec extends ScalaTest { } object RefinedNysiisAlgorithmSpec { - final private val Algorithm = new RefinedNysiisAlgorithm + final private val Algorithm = RefinedNysiisAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala index 59305b6..14ea64b 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class RefinedNysiisMetricSpec extends ScalaTest { - import RefinedNysiisMetricSpec._ + import RefinedNysiisMetricSpec.Metric "RefinedNysiisMetric" should provide { "compare method" when passed { @@ -39,5 +39,5 @@ final class RefinedNysiisMetricSpec extends ScalaTest { } object RefinedNysiisMetricSpec { - final private val Metric = new RefinedNysiisMetric + final private val Metric = RefinedNysiisMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala index e52365c..0c78fe7 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class RefinedSoundexAlgorithmSpec extends ScalaTest { - import RefinedSoundexAlgorithmSpec._ + import RefinedSoundexAlgorithmSpec.Algorithm "RefinedSoundexAlgorithm" should provide { "compute method" when passed { @@ -164,5 +164,5 @@ final class RefinedSoundexAlgorithmSpec extends ScalaTest { } object RefinedSoundexAlgorithmSpec { - final private val Algorithm = new RefinedSoundexAlgorithm + final private val Algorithm = RefinedSoundexAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala index dd9bd04..0f3a244 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class RefinedSoundexMetricSpec extends ScalaTest { - import RefinedSoundexMetricSpec._ + import RefinedSoundexMetricSpec.Metric "RefinedSoundexMetric" should provide { "compare method" when passed { @@ -39,5 +39,5 @@ final class RefinedSoundexMetricSpec extends ScalaTest { } object RefinedSoundexMetricSpec { - final private val Metric = new RefinedSoundexMetric + final private val Metric = RefinedSoundexMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala index 6b286e5..8f1be8d 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class SoundexAlgorithmSpec extends ScalaTest { - import SoundexAlgorithmSpec._ + import SoundexAlgorithmSpec.Algorithm "SoundexAlgorithm" should provide { "compute method" when passed { @@ -163,5 +163,5 @@ final class SoundexAlgorithmSpec extends ScalaTest { } object SoundexAlgorithmSpec { - final private val Algorithm = new SoundexAlgorithm + final private val Algorithm = SoundexAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala index 5758f86..98bb28b 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class SoundexMetricSpec extends ScalaTest { - import SoundexMetricSpec._ + import SoundexMetricSpec.Metric "SoundexMetric" should provide { "compare method" when passed { @@ -39,5 +39,5 @@ final class SoundexMetricSpec extends ScalaTest { } object SoundexMetricSpec { - final private val Metric = new SoundexMetric + final private val Metric = SoundexMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala index b05a4fc..fd03889 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class DiceSorensenMetricSpec extends ScalaTest { - import DiceSorensenMetricSpec._ + import DiceSorensenMetricSpec.Metric "DiceSorensenMetric" should provide { "compare method" when passed { @@ -64,5 +64,5 @@ final class DiceSorensenMetricSpec extends ScalaTest { } object DiceSorensenMetricSpec { - private final val Metric = new DiceSorensenMetric + private final val Metric = DiceSorensenMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala index ede84ad..f363d73 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class HammingMetricSpec extends ScalaTest { - import HammingMetricSpec._ + import HammingMetricSpec.Metric "HammingMetric" should provide { "compare method" when passed { @@ -41,5 +41,5 @@ final class HammingMetricSpec extends ScalaTest { } object HammingMetricSpec { - private final val Metric = new HammingMetric + private final val Metric = HammingMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala index 5b99619..692ec9d 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class JaroMetricSpec extends ScalaTest { - import JaroMetricSpec._ + import JaroMetricSpec.Metric "JaroMetric" should provide { "compare method" when passed { @@ -55,5 +55,5 @@ final class JaroMetricSpec extends ScalaTest { } object JaroMetricSpec { - private final val Metric = new JaroMetric + private final val Metric = JaroMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala index d9fe4b7..6ee44d1 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class JaroWinklerMetricSpec extends ScalaTest { - import JaroWinklerMetricSpec._ + import JaroWinklerMetricSpec.Metric "JaroWinklerMetric" should provide { "compare method" when passed { @@ -55,5 +55,5 @@ final class JaroWinklerMetricSpec extends ScalaTest { } object JaroWinklerMetricSpec { - private final val Metric = new JaroWinklerMetric + private final val Metric = JaroWinklerMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala index ac45a21..c0a183e 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class LevenshteinMetricSpec extends ScalaTest { - import LevenshteinMetricSpec._ + import LevenshteinMetricSpec.Metric "LevenshteinMetric" should provide { "compare method" when passed { @@ -54,5 +54,5 @@ final class LevenshteinMetricSpec extends ScalaTest { } object LevenshteinMetricSpec { - private final val Metric = new LevenshteinMetric + private final val Metric = LevenshteinMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmSpec.scala index ffeefb0..87d2a3d 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramAlgorithmSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class NGramAlgorithmSpec extends ScalaTest { - import NGramAlgorithmSpec._ + import NGramAlgorithmSpec.Algorithm "NGramAlgorithm" should provide { "compute method" when passed { @@ -53,5 +53,5 @@ final class NGramAlgorithmSpec extends ScalaTest { } object NGramAlgorithmSpec { - private final val Algorithm = new NGramAlgorithm + private final val Algorithm = NGramAlgorithm() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala index 0f09ab1..20a17c4 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class NGramMetricSpec extends ScalaTest { - import NGramMetricSpec._ + import NGramMetricSpec.Metric "NGramMetric" should provide { "compare method" when passed { @@ -64,5 +64,5 @@ final class NGramMetricSpec extends ScalaTest { } object NGramMetricSpec { - private final val Metric = new NGramMetric + private final val Metric = NGramMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala index d6a8d45..445c2b6 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class RatcliffObershelpMetricSpec extends ScalaTest { - import RatcliffObershelpMetricSpec._ + import RatcliffObershelpMetricSpec.Metric "RatcliffObershelpMetric" should provide { "compare method" when passed { @@ -44,6 +44,6 @@ final class RatcliffObershelpMetricSpec extends ScalaTest { } object RatcliffObershelpMetricSpec { - private final val Metric = new RatcliffObershelpMetric + private final val Metric = RatcliffObershelpMetric() } diff --git a/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala index 5665d7c..c93e652 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala @@ -6,7 +6,7 @@ import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) final class WeightedLevenshteinMetricSpec extends ScalaTest { - import WeightedLevenshteinMetricSpec._ + import WeightedLevenshteinMetricSpec.{ Metric, Options } "WeightedLevenshteinMetric" should provide { "compare method" when passed { @@ -53,5 +53,5 @@ final class WeightedLevenshteinMetricSpec extends ScalaTest { object WeightedLevenshteinMetricSpec { private final val Options = Tuple3[BigDecimal, BigDecimal, BigDecimal](10, 0.1, 1) - private final val Metric = new WeightedLevenshteinMetric + private final val Metric = WeightedLevenshteinMetric() } -- cgit v1.2.3