summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-10-16 00:12:06 -0600
committerRocky Madden <git@rockymadden.com>2012-10-16 00:12:06 -0600
commit61f2ddf07826d3b278eb17d31ffbb5bfdbdc56ca (patch)
tree33f01d986e03dc5143ce0a90d6074447b8338e6e /core
parent509be5d66c6a5c83a636d1f0bc1bad183c2a723e (diff)
downloadstringmetric-61f2ddf07826d3b278eb17d31ffbb5bfdbdc56ca.tar.gz
stringmetric-61f2ddf07826d3b278eb17d31ffbb5bfdbdc56ca.tar.bz2
stringmetric-61f2ddf07826d3b278eb17d31ffbb5bfdbdc56ca.zip
Changed from package level implicit for stringCleaner to per metric based.
Diffstat (limited to 'core')
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/package.scala2
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala1
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala3
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala3
-rwxr-xr-xcore/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala1
9 files changed, 12 insertions, 6 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala
index 67fd3e5..687ffba 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala
@@ -2,6 +2,8 @@ package org.hashtree.stringmetric
/** An implementation of the Hamming [[org.hashtree.stringmetric.StringMetric]]. */
object HammingMetric extends StringMetric {
+ implicit val stringCleaner = new StringCleanerDelegate with CaseStringCleaner
+
override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Int] = {
if (charArray1.length == 0 || charArray2.length == 0 || charArray2.length != charArray2.length)
None
diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala
index fb9a3e4..4db130c 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala
@@ -9,6 +9,8 @@ import scala.math
* distance in these scenarios.
*/
object JaroMetric extends StringMetric {
+ implicit val stringCleaner = new StringCleanerDelegate with CaseStringCleaner with SpaceStringCleaner
+
override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Float] = {
val ca1 = stringCleaner.clean(charArray1)
val ca2 = stringCleaner.clean(charArray2)
diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala
index 8292c55..8fc554c 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala
@@ -6,6 +6,8 @@ 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 {
+ implicit val stringCleaner = new StringCleanerDelegate with CaseStringCleaner with SpaceStringCleaner
+
override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Float] = {
val ca1 = stringCleaner.clean(charArray1)
val ca2 = stringCleaner.clean(charArray2)
diff --git a/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala
index 3d19f5b..714f2f7 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala
@@ -4,6 +4,8 @@ import scala.annotation.tailrec
/** An implementation of the Soundex [[org.hashtree.stringmetric.StringMetric]]. */
object SoundexMetric extends StringMetric {
+ implicit val stringCleaner = new StringCleanerDelegate
+
override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Boolean] = {
val se1 = if (charArray1.length > 0) soundex(stringCleaner.clean(charArray1)) else None
val se2 = if (charArray2.length > 0) soundex(stringCleaner.clean(charArray2)) else None
diff --git a/core/source/core/scala/org/hashtree/stringmetric/package.scala b/core/source/core/scala/org/hashtree/stringmetric/package.scala
index 89bfee4..3be74fb 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/package.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/package.scala
@@ -5,6 +5,4 @@ package object stringmetric {
type CompareTuple = Tuple2[Array[Char], Array[Char]]
type MatchTuple = CompareTuple
-
- implicit val stringCleaner = new StringCleanerDelegate
} \ No newline at end of file
diff --git a/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala
index 641bbde..5fd0e26 100755
--- a/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala
+++ b/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala
@@ -1,5 +1,6 @@
package org.hashtree.stringmetric
+import org.hashtree.stringmetric.HammingMetric.stringCleaner
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
index a9eeed1..d1682ad 100755
--- a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
+++ b/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala
@@ -1,12 +1,11 @@
package org.hashtree.stringmetric
+import org.hashtree.stringmetric.JaroMetric.stringCleaner
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
final class JaroMetricSpec extends ScalaTest {
- implicit val stringMetric = new StringCleanerDelegate with CaseStringCleaner with SpaceStringCleaner
-
"JaroMetric" should provide {
"compare method" when passed {
"valid arguments" should returns {
diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala
index 9da716a..550a188 100755
--- a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala
+++ b/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala
@@ -1,12 +1,11 @@
package org.hashtree.stringmetric
+import org.hashtree.stringmetric.JaroWinklerMetric.stringCleaner
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
final class JaroWinklerMetricSpec extends ScalaTest {
- implicit val stringMetric = new StringCleanerDelegate with CaseStringCleaner with SpaceStringCleaner
-
"JaroWinklerMetric" should provide {
"compare method" when passed {
"valid arguments" should returns {
diff --git a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala
index 6e7b6d9..8530d92 100755
--- a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala
+++ b/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala
@@ -1,5 +1,6 @@
package org.hashtree.stringmetric
+import org.hashtree.stringmetric.SoundexMetric.stringCleaner
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner