diff options
author | Rocky Madden <git@rockymadden.com> | 2012-10-20 15:07:15 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-10-20 15:07:15 -0600 |
commit | f9ceaad11b584dffcd360bba7893dd4bbf4047bd (patch) | |
tree | aea002b9ebeb6e61c50001edeac4ccb8763431fc /core | |
parent | 2d0dd08d02cf5eac514cfe0d2201baaa79e38a2d (diff) | |
download | stringmetric-f9ceaad11b584dffcd360bba7893dd4bbf4047bd.tar.gz stringmetric-f9ceaad11b584dffcd360bba7893dd4bbf4047bd.tar.bz2 stringmetric-f9ceaad11b584dffcd360bba7893dd4bbf4047bd.zip |
Restructured metrics into subpackages. One for distance and one for phonetic.
Diffstat (limited to 'core')
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala (renamed from core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala) | 6 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala (renamed from core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala) | 6 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/distance/JaroWinklerMetric.scala (renamed from core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala) | 6 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala (renamed from core/source/core/scala/org/hashtree/stringmetric/LevenshteinMetric.scala) | 6 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/package.scala | 2 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala (renamed from core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala) | 3 | ||||
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala (renamed from core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala) | 4 | ||||
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala (renamed from core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala) | 4 | ||||
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala (renamed from core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala) | 4 | ||||
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala (renamed from core/source/test/scala/org/hashtree/stringmetric/LevenshteinMetricSpec.scala) | 4 | ||||
-rwxr-xr-x | core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexMetricSpec.scala (renamed from core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala) | 4 |
11 files changed, 24 insertions, 25 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala index 0a7ebd3..f8fe982 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/HammingMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala @@ -1,9 +1,9 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance + +import org.hashtree.stringmetric.{ CompareTuple, StringCleaner, StringCleanerDelegate, 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] = { val ca1 = stringCleaner.clean(charArray1) val ca2 = stringCleaner.clean(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala index 7af4933..6309bc5 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala @@ -1,7 +1,7 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance +import org.hashtree.stringmetric.{ CompareTuple, MatchTuple, StringCleaner, StringCleanerDelegate, StringMetric } import scala.collection.mutable.{ ArrayBuffer, HashSet } -import scala.math /** * An implementation of the Jaro [[org.hashtree.stringmetric.StringMetric]]. One differing detail in this implementation @@ -9,8 +9,6 @@ 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/distance/JaroWinklerMetric.scala index 85a0736..568a69e 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/distance/JaroWinklerMetric.scala @@ -1,4 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance + +import org.hashtree.stringmetric.{ StringCleaner, StringCleanerDelegate, StringMetric } /** * An implementation of the Jaro-Winkler [[org.hashtree.stringmetric.StringMetric]]. One differing detail in this @@ -6,8 +8,6 @@ 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/LevenshteinMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala index 9465c66..9925b57 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/LevenshteinMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala @@ -1,11 +1,9 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance -import scala.math +import org.hashtree.stringmetric.{ CompareTuple, StringCleaner, StringCleanerDelegate, StringMetric } /** An implementation of the Levenshtein [[org.hashtree.stringmetric.StringMetric]]. */ object LevenshteinMetric extends StringMetric { - implicit val stringCleaner = new StringCleanerDelegate with CaseStringCleaner - override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Option[Int] = { val ca1 = stringCleaner.clean(charArray1) val ca2 = stringCleaner.clean(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/package.scala b/core/source/core/scala/org/hashtree/stringmetric/package.scala index 3be74fb..89bfee4 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/package.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/package.scala @@ -5,4 +5,6 @@ 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/core/scala/org/hashtree/stringmetric/SoundexMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala index 3c3ee5b..c8f2d13 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/SoundexMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala @@ -1,5 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.phonetic +import org.hashtree.stringmetric.{ StringCleaner, StringCleanerDelegate, StringMetric } import scala.annotation.tailrec /** An implementation of the Soundex [[org.hashtree.stringmetric.StringMetric]]. */ diff --git a/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala index 5fd0e26..21608c2 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/HammingMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/HammingMetricSpec.scala @@ -1,6 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance -import org.hashtree.stringmetric.HammingMetric.stringCleaner +import org.hashtree.stringmetric.ScalaTest 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/distance/JaroMetricSpec.scala index d1682ad..f07a4e9 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/JaroMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroMetricSpec.scala @@ -1,6 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance -import org.hashtree.stringmetric.JaroMetric.stringCleaner +import org.hashtree.stringmetric.ScalaTest import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner diff --git a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala index 550a188..0e52b4f 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/JaroWinklerMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/JaroWinklerMetricSpec.scala @@ -1,6 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance -import org.hashtree.stringmetric.JaroWinklerMetric.stringCleaner +import org.hashtree.stringmetric.ScalaTest import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner diff --git a/core/source/test/scala/org/hashtree/stringmetric/LevenshteinMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala index 01c9082..07e3a94 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/LevenshteinMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/distance/LevenshteinMetricSpec.scala @@ -1,6 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.distance -import org.hashtree.stringmetric.LevenshteinMetric.stringCleaner +import org.hashtree.stringmetric.ScalaTest import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner diff --git a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexMetricSpec.scala index 8530d92..6664696 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/SoundexMetricSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexMetricSpec.scala @@ -1,6 +1,6 @@ -package org.hashtree.stringmetric +package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.SoundexMetric.stringCleaner +import org.hashtree.stringmetric.ScalaTest import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner |