diff options
Diffstat (limited to 'core')
28 files changed, 98 insertions, 80 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/Algorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/Algorithm.scala index cd46150..3604eb2 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/Algorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/Algorithm.scala @@ -1,6 +1,6 @@ package org.hashtree.stringmetric -/** Marks those which leverage traits of a stand alone algorithm. */ -trait Algorithm[T, F <: Filter[T]] { - def compute(t: T)(implicit f: F): Option[T] +/** Marks those which leverage traits of a standalone algorithm. */ +trait Algorithm[T] { + }
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableAlgorithm.scala new file mode 100755 index 0000000..f59781d --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableAlgorithm.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a filterable [[org.hashtree.stringmetric.Algorithm]]. */ +trait FilterableAlgorithm[T, F <: Filter[T]] extends Algorithm[T] { + def compute(t: T)(implicit f: F): Option[T] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableAlgorithm.scala new file mode 100755 index 0000000..2f6287e --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableAlgorithm.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a filterable and configurable [[org.hashtree.stringmetric.Algorithm]]. */ +trait FilterableConfigurableAlgorithm[T, O, F <: Filter[T]] extends Algorithm[T] { + def compute(t: T)(o: O)(implicit f: F): Option[T] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableMetric.scala new file mode 100755 index 0000000..0c15698 --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableMetric.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a filterable and configurable [[org.hashtree.stringmetric.Metric]]. */ +trait FilterableConfigurableMetric[T, O, F <: Filter[T]] extends Metric[T] { + def compare(t1: T, t2: T)(o: O)(implicit f: F): Option[AnyVal] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringAlgorithm.scala new file mode 100755 index 0000000..af9af1a --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringAlgorithm.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.FilterableConfigurableAlgorithm]]. */ +trait FilterableConfigurableStringAlgorithm[O] extends FilterableConfigurableAlgorithm[String, O, StringFilter] with StringAlgorithm { + def compute(charArray: Array[Char])(o: O)(implicit stringFilter: StringFilter): Option[Array[Char]] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringMetric.scala new file mode 100755 index 0000000..40bff14 --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableConfigurableStringMetric.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.FilterableConfigurableMetric]]. */ +trait FilterableConfigurableStringMetric[O] extends FilterableConfigurableMetric[String, O, StringFilter] with StringMetric { + def compare(charArray1: Array[Char], charArray2: Array[Char])(o: O)(implicit stringFilter: StringFilter): Option[AnyVal] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableMetric.scala new file mode 100755 index 0000000..2d94865 --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableMetric.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a filterable [[org.hashtree.stringmetric.Metric]]. */ +trait FilterableMetric[T, F <: Filter[T]] extends Metric[T] { + def compare(t1: T, t2: T)(implicit f: F): Option[AnyVal] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableStringAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableStringAlgorithm.scala new file mode 100755 index 0000000..f6cff27 --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableStringAlgorithm.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.FilterableAlgorithm]]. */ +trait FilterableStringAlgorithm extends FilterableAlgorithm[String, StringFilter] with StringAlgorithm { + def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/FilterableStringMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/FilterableStringMetric.scala new file mode 100755 index 0000000..3ad21da --- /dev/null +++ b/core/source/core/scala/org/hashtree/stringmetric/FilterableStringMetric.scala @@ -0,0 +1,6 @@ +package org.hashtree.stringmetric + +/** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.FilterableMetric]]. */ +trait FilterableStringMetric extends FilterableMetric[String, StringFilter] with StringMetric { + def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[AnyVal] +}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/Metric.scala b/core/source/core/scala/org/hashtree/stringmetric/Metric.scala index 9542dcf..684118f 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/Metric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/Metric.scala @@ -1,6 +1,6 @@ package org.hashtree.stringmetric /** Marks those which leverage traits of a metric. */ -trait Metric[T, F <: Filter[T]] { - def compare(t1: T, t2: T)(implicit f: F): Option[AnyVal] +trait Metric[T] { + }
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/OptionMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/OptionMetric.scala deleted file mode 100755 index 1a942e0..0000000 --- a/core/source/core/scala/org/hashtree/stringmetric/OptionMetric.scala +++ /dev/null @@ -1,6 +0,0 @@ -package org.hashtree.stringmetric - -/** Marks those which leverage traits of an option metric. */ -trait OptionMetric[T, O, F <: Filter[T]] { - def compare(t1: T, t2: T)(o: O)(implicit f: F): Option[AnyVal] -}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala index ceac3b5..5c90152 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala @@ -3,8 +3,8 @@ package org.hashtree.stringmetric import org.hashtree.stringmetric.phonetic.{ MetaphoneAlgorithm, NysiisAlgorithm, RefinedSoundexAlgorithm, SoundexAlgorithm } /** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.Algorithm]]. */ -trait StringAlgorithm extends Algorithm[String, StringFilter] { - def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] +trait StringAlgorithm extends Algorithm[String] { + } /** Convenience object for those extending [[org.hashtree.stringmetric.StringAlgorithm]]. */ diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala index add00d2..ccc1ced 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala @@ -1,11 +1,11 @@ package org.hashtree.stringmetric import org.hashtree.stringmetric.phonetic.{ MetaphoneMetric, NysiisMetric, RefinedSoundexMetric, SoundexMetric } -import org.hashtree.stringmetric.similarity.{ DiceSorensenMetric, HammingMetric, JaroMetric, JaroWinklerMetric, LevenshteinMetric } +import org.hashtree.stringmetric.similarity.{ DiceSorensenMetric, HammingMetric, JaroMetric, JaroWinklerMetric, LevenshteinMetric, WeightedLevenshteinMetric } /** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.Metric]]. */ -trait StringMetric extends Metric[String, StringFilter] { - def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[AnyVal] +trait StringMetric extends Metric[String] { + } /** Convenience object for those extending [[org.hashtree.stringmetric.StringMetric]]. */ @@ -64,6 +64,14 @@ object StringMetric { def compareSoundex(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Boolean] = SoundexMetric.compare(string1, string2)(stringFilter) + def compareWeightedLevenshtein(charArray1: Array[Char], charArray2: Array[Char]) + (options: Tuple3[BigDecimal, BigDecimal, BigDecimal])(implicit stringFilter: StringFilter): Option[Double] = + WeightedLevenshteinMetric.compare(charArray1, charArray2)(options)(stringFilter) + + def compareWeightedLevenshtein(string1: String, string2: String) + (options: Tuple3[BigDecimal, BigDecimal, BigDecimal])(implicit stringFilter: StringFilter): Option[Double] = + WeightedLevenshteinMetric.compare(string1, string2)(options)(stringFilter) + def diceSorensen: DiceSorensenMetric.type = DiceSorensenMetric def hamming: HammingMetric.type = HammingMetric @@ -81,4 +89,6 @@ object StringMetric { def refinedSoundex: RefinedSoundexMetric.type = RefinedSoundexMetric def soundex: SoundexMetric.type = SoundexMetric + + def weightedLevenshtein: WeightedLevenshteinMetric.type = WeightedLevenshteinMetric }
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringOptionMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/StringOptionMetric.scala deleted file mode 100755 index a40273f..0000000 --- a/core/source/core/scala/org/hashtree/stringmetric/StringOptionMetric.scala +++ /dev/null @@ -1,21 +0,0 @@ -package org.hashtree.stringmetric - -import org.hashtree.stringmetric.similarity.WeightedLevenshteinMetric - -/** Marks those which leverage traits of a string based [[org.hashtree.stringmetric.OptionMetric]]. */ -trait StringOptionMetric[O] extends OptionMetric[String, O, StringFilter] { - def compare(charArray1: Array[Char], charArray2: Array[Char])(o: O)(implicit stringFilter: StringFilter): Option[AnyVal] -} - -/** Convenience object for those extending [[org.hashtree.stringmetric.StringOptionMetric]]. */ -object StringOptionMetric { - def compareWeightedLevenshtein(charArray1: Array[Char], charArray2: Array[Char]) - (options: Tuple3[BigDecimal, BigDecimal, BigDecimal])(implicit stringFilter: StringFilter): Option[Double] = - WeightedLevenshteinMetric.compare(charArray1, charArray2)(options)(stringFilter) - - def compareWeightedLevenshtein(string1: String, string2: String) - (options: Tuple3[BigDecimal, BigDecimal, BigDecimal])(implicit stringFilter: StringFilter): Option[Double] = - WeightedLevenshteinMetric.compare(string1, string2)(options)(stringFilter) - - def weightedLevenshtein: WeightedLevenshteinMetric.type = WeightedLevenshteinMetric -}
\ No newline at end of file diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala index c76a6e2..81b4069 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala @@ -1,11 +1,10 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringAlgorithm, StringFilter } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter, StringFilterDelegate } import scala.annotation.tailrec /** An implementation of the Metaphone [[org.hashtree.stringmetric.StringAlgorithm]]. */ -object MetaphoneAlgorithm extends StringAlgorithm { +object MetaphoneAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { override def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = { val ca = stringFilter.filter(charArray) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneMetric.scala index f1bb840..88a0a7c 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringMetric, StringFilter, StringFilterDelegate, StringMetric } /** An implementation of the Metaphone [[org.hashtree.stringmetric.StringMetric]]. */ -object MetaphoneMetric extends StringMetric { +object MetaphoneMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala index b4bf5e7..45b6f3f 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala @@ -1,11 +1,10 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringAlgorithm, StringFilter } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter, StringFilterDelegate } import scala.annotation.tailrec /** An implementation of the NYSIIS [[org.hashtree.stringmetric.StringAlgorithm]]. */ -object NysiisAlgorithm extends StringAlgorithm { +object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { override def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = { val ca = stringFilter.filter(charArray) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisMetric.scala index 89b9bd9..60e8ff6 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringMetric, StringFilter, StringFilterDelegate, StringMetric } /** An implementation of the NYSIIS [[org.hashtree.stringmetric.StringMetric]]. */ -object NysiisMetric extends StringMetric { +object NysiisMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala index 7b50922..4007021 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala @@ -1,11 +1,10 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringAlgorithm, StringFilter } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter, StringFilterDelegate } import scala.annotation.tailrec /** An implementation of the refined Soundex [[org.hashtree.stringmetric.StringAlgorithm]]. */ -object RefinedSoundexAlgorithm extends StringAlgorithm { +object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { override def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = { val ca = stringFilter.filter(charArray) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetric.scala index 9c7a7a0..5ba26cb 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringMetric, StringFilter, StringFilterDelegate, StringMetric } /** An implementation of the refined Soundex [[org.hashtree.stringmetric.StringMetric]]. */ -object RefinedSoundexMetric extends StringMetric { +object RefinedSoundexMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala index ca2e840..41636bb 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala @@ -1,11 +1,10 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringAlgorithm, StringFilter } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter, StringFilterDelegate } import scala.annotation.tailrec /** An implementation of the Soundex [[org.hashtree.stringmetric.StringAlgorithm]]. */ -object SoundexAlgorithm extends StringAlgorithm { +object SoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { override def compute(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = { val ca = stringFilter.filter(charArray) diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala index 91d94ab..c86eef8 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.phonetic -import org.hashtree.stringmetric.{ StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringMetric, StringFilter, StringFilterDelegate, StringMetric } /** An implementation of the Soundex [[org.hashtree.stringmetric.StringMetric]]. */ -object SoundexMetric extends StringMetric { +object SoundexMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetric.scala index 5bf8509..64447d6 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/DiceSorensenMetric.scala @@ -1,11 +1,10 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ CompareTuple, MatchTuple, StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ CompareTuple, FilterableStringMetric, MatchTuple, StringFilter, StringMetric, StringFilterDelegate } import scala.annotation.tailrec /** An implementation of the Dice, and Sorensen, [[org.hashtree.stringmetric.StringMetric]]. */ -object DiceSorensenMetric extends StringMetric { +object DiceSorensenMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/HammingMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/HammingMetric.scala index ec3de5c..61c241b 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/HammingMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/HammingMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ CompareTuple, StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ CompareTuple, FilterableStringMetric, StringFilter, StringMetric, StringFilterDelegate } /** An implementation of the Hamming [[org.hashtree.stringmetric.StringMetric]]. */ -object HammingMetric extends StringMetric { +object HammingMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Int] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroMetric.scala index 4363ba7..0e707c8 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroMetric.scala @@ -1,7 +1,6 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ CompareTuple, MatchTuple, StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ CompareTuple, FilterableStringMetric, MatchTuple, StringFilter, StringMetric, StringFilterDelegate } import scala.collection.mutable.{ ArrayBuffer, HashSet } /** @@ -9,7 +8,7 @@ import scala.collection.mutable.{ ArrayBuffer, HashSet } * is that if a character is matched in string2, it cannot be matched upon again. This results in a more penalized * distance in these scenarios. */ -object JaroMetric extends StringMetric { +object JaroMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroWinklerMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroWinklerMetric.scala index 98f6969..c964ed9 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroWinklerMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/JaroWinklerMetric.scala @@ -1,14 +1,13 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ FilterableStringMetric, StringFilter, StringMetric, StringFilterDelegate } /** * An implementation of the Jaro-Winkler [[org.hashtree.stringmetric.StringMetric]]. One differing detail in this * implementation is that if a character is matched in string2, it cannot be matched upon again. This results in a more * penalized distance in these scenarios (e.g. comparing henka and henkan distance is 0.9666 versus the typical 0.9722). */ -object JaroWinklerMetric extends StringMetric { +object JaroWinklerMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/LevenshteinMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/LevenshteinMetric.scala index df85da4..3d87caf 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/LevenshteinMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/LevenshteinMetric.scala @@ -1,10 +1,9 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ CompareTuple, StringFilter, StringMetric } -import org.hashtree.stringmetric.StringFilterDelegate +import org.hashtree.stringmetric.{ CompareTuple, FilterableStringMetric, StringFilter, StringFilterDelegate, StringMetric } /** An implementation of the Levenshtein [[org.hashtree.stringmetric.StringMetric]]. */ -object LevenshteinMetric extends StringMetric { +object LevenshteinMetric extends StringMetric with FilterableStringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Int] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) diff --git a/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala index 545f0ee..703b75a 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala @@ -1,12 +1,12 @@ package org.hashtree.stringmetric.similarity -import org.hashtree.stringmetric.{ CompareTuple, StringFilter, StringFilterDelegate, StringOptionMetric } +import org.hashtree.stringmetric.{ CompareTuple, FilterableConfigurableStringMetric, StringFilter, StringFilterDelegate, StringMetric } import scala.math.BigDecimal -/** An implementation of a weighted Levenshtein [[org.hashtree.stringmetric.StringOptionMetric]]. */ -object WeightedLevenshteinMetric extends StringOptionMetric[Tuple3[BigDecimal, BigDecimal, BigDecimal]] { +/** An implementation of a weighted Levenshtein [[org.hashtree.stringmetric.StringMetric]]. */ +object WeightedLevenshteinMetric extends StringMetric with FilterableConfigurableStringMetric[Tuple3[BigDecimal, BigDecimal, BigDecimal]] { /** Options order is delete, insert, then substitute weight. */ - def compare(charArray1: Array[Char], charArray2: Array[Char])(options: Tuple3[BigDecimal, BigDecimal, BigDecimal]) + override def compare(charArray1: Array[Char], charArray2: Array[Char])(options: Tuple3[BigDecimal, BigDecimal, BigDecimal]) (implicit stringFilter: StringFilter): Option[Double] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) |