diff options
author | Rocky Madden <git@rockymadden.com> | 2012-11-02 08:31:36 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-11-02 08:31:36 -0600 |
commit | 9afb69d19a20ed2447b56bbd9c9c7b9552103d90 (patch) | |
tree | f15f5374f260201c80227fa85be639473775694b /core | |
parent | 962c54ecedb81dd6db177ce743b8724e15f4ad8a (diff) | |
download | stringmetric-9afb69d19a20ed2447b56bbd9c9c7b9552103d90.tar.gz stringmetric-9afb69d19a20ed2447b56bbd9c9c7b9552103d90.tar.bz2 stringmetric-9afb69d19a20ed2447b56bbd9c9c7b9552103d90.zip |
Added curry with implicit StringFilter.
Diffstat (limited to 'core')
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala | 24 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala | 72 |
2 files changed, 52 insertions, 44 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala index 0878ea2..ceac3b5 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/StringAlgorithm.scala @@ -9,21 +9,29 @@ trait StringAlgorithm extends Algorithm[String, StringFilter] { /** Convenience object for those extending [[org.hashtree.stringmetric.StringAlgorithm]]. */ object StringAlgorithm { - def computeMetaphone(charArray: Array[Char]): Option[Array[Char]] = MetaphoneAlgorithm.compute(charArray) + def computeMetaphone(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = + MetaphoneAlgorithm.compute(charArray)(stringFilter) - def computeMetaphone(string: String): Option[String] = MetaphoneAlgorithm.compute(string) + def computeMetaphone(string: String)(implicit stringFilter: StringFilter): Option[String] = + MetaphoneAlgorithm.compute(string)(stringFilter) - def computeNysiis(charArray: Array[Char]): Option[Array[Char]] = NysiisAlgorithm.compute(charArray) + def computeNysiis(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = + NysiisAlgorithm.compute(charArray)(stringFilter) - def computeNysiis(string: String): Option[String] = NysiisAlgorithm.compute(string) + def computeNysiis(string: String)(implicit stringFilter: StringFilter): Option[String] = + NysiisAlgorithm.compute(string)(stringFilter) - def computeRefinedSoundex(charArray: Array[Char]): Option[Array[Char]] = RefinedSoundexAlgorithm.compute(charArray) + def computeRefinedSoundex(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = + RefinedSoundexAlgorithm.compute(charArray)(stringFilter) - def computeRefinedSoundex(string: String): Option[String] = RefinedSoundexAlgorithm.compute(string) + def computeRefinedSoundex(string: String)(implicit stringFilter: StringFilter): Option[String] = + RefinedSoundexAlgorithm.compute(string)(stringFilter) - def computeSoundex(charArray: Array[Char]): Option[Array[Char]] = SoundexAlgorithm.compute(charArray) + def computeSoundex(charArray: Array[Char])(implicit stringFilter: StringFilter): Option[Array[Char]] = + SoundexAlgorithm.compute(charArray)(stringFilter) - def computeSoundex(string: String): Option[String] = SoundexAlgorithm.compute(string) + def computeSoundex(string: String)(implicit stringFilter: StringFilter): Option[String] = + SoundexAlgorithm.compute(string)(stringFilter) def metaphone: MetaphoneAlgorithm.type = MetaphoneAlgorithm diff --git a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala index 5cd5f69..add00d2 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/StringMetric.scala @@ -10,59 +10,59 @@ trait StringMetric extends Metric[String, StringFilter] { /** Convenience object for those extending [[org.hashtree.stringmetric.StringMetric]]. */ object StringMetric { - def compareDiceSorensen(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = - DiceSorensenMetric.compare(charArray1, charArray2) + def compareDiceSorensen(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = + DiceSorensenMetric.compare(charArray1, charArray2)(stringFilter) - def compareDiceSorensen(string1: String, string2: String): Option[Double] = - DiceSorensenMetric.compare(string1, string2) + def compareDiceSorensen(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Double] = + DiceSorensenMetric.compare(string1, string2)(stringFilter) - def compareHamming(charArray1: Array[Char], charArray2: Array[Char]): Option[Int] = - HammingMetric.compare(charArray1, charArray2) + def compareHamming(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Int] = + HammingMetric.compare(charArray1, charArray2)(stringFilter) - def compareHamming(string1: String, string2: String): Option[Int] = - HammingMetric.compare(string1, string2) + def compareHamming(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Int] = + HammingMetric.compare(string1, string2)(stringFilter) - def compareJaro(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = - JaroMetric.compare(charArray1, charArray2) + def compareJaro(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = + JaroMetric.compare(charArray1, charArray2)(stringFilter) - def compareJaro(string1: String, string2: String): Option[Double] = - JaroMetric.compare(string1, string2) + def compareJaro(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Double] = + JaroMetric.compare(string1, string2)(stringFilter) - def compareJaroWinkler(charArray1: Array[Char], charArray2: Array[Char]): Option[Double] = - JaroWinklerMetric.compare(charArray1, charArray2) + def compareJaroWinkler(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Double] = + JaroWinklerMetric.compare(charArray1, charArray2)(stringFilter) - def compareJaroWinkler(string1: String, string2: String): Option[Double] = - JaroWinklerMetric.compare(string1, string2) + def compareJaroWinkler(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Double] = + JaroWinklerMetric.compare(string1, string2)(stringFilter) - def compareLevenshtein(charArray1: Array[Char], charArray2: Array[Char]): Option[Int] = - LevenshteinMetric.compare(charArray1, charArray2) + def compareLevenshtein(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Int] = + LevenshteinMetric.compare(charArray1, charArray2)(stringFilter) - def compareLevenshtein(string1: String, string2: String): Option[Int] = - LevenshteinMetric.compare(string1, string2) + def compareLevenshtein(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Int] = + LevenshteinMetric.compare(string1, string2)(stringFilter) - def compareMetaphone(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = - MetaphoneMetric.compare(charArray1, charArray2) + def compareMetaphone(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = + MetaphoneMetric.compare(charArray1, charArray2)(stringFilter) - def compareMetaphone(string1: String, string2: String): Option[Boolean] = - MetaphoneMetric.compare(string1, string2) + def compareMetaphone(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Boolean] = + MetaphoneMetric.compare(string1, string2)(stringFilter) - def compareNysiis(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = - NysiisMetric.compare(charArray1, charArray2) + def compareNysiis(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = + NysiisMetric.compare(charArray1, charArray2)(stringFilter) - def compareNysiis(string1: String, string2: String): Option[Boolean] = - NysiisMetric.compare(string1, string2) + def compareNysiis(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Boolean] = + NysiisMetric.compare(string1, string2)(stringFilter) - def compareRefinedSoundex(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = - RefinedSoundexMetric.compare(charArray1, charArray2) + def compareRefinedSoundex(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = + RefinedSoundexMetric.compare(charArray1, charArray2)(stringFilter) - def compareRefinedSoundex(string1: String, string2: String): Option[Boolean] = - RefinedSoundexMetric.compare(string1, string2) + def compareRefinedSoundex(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Boolean] = + RefinedSoundexMetric.compare(string1, string2)(stringFilter) - def compareSoundex(charArray1: Array[Char], charArray2: Array[Char]): Option[Boolean] = - SoundexMetric.compare(charArray1, charArray2) + def compareSoundex(charArray1: Array[Char], charArray2: Array[Char])(implicit stringFilter: StringFilter): Option[Boolean] = + SoundexMetric.compare(charArray1, charArray2)(stringFilter) - def compareSoundex(string1: String, string2: String): Option[Boolean] = - SoundexMetric.compare(string1, string2) + def compareSoundex(string1: String, string2: String)(implicit stringFilter: StringFilter): Option[Boolean] = + SoundexMetric.compare(string1, string2)(stringFilter) def diceSorensen: DiceSorensenMetric.type = DiceSorensenMetric |