diff options
author | Rocky Madden <git@rockymadden.com> | 2012-11-09 10:07:21 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-11-09 10:07:21 -0700 |
commit | a825efe0b41c8a868a2da3024d8cbeb2cf594413 (patch) | |
tree | 58575dba90dafbc14966cbf86a2f3153cd658764 /core | |
parent | 356f1b738c1a74fc32e7cd31ce8e651cb47334fd (diff) | |
download | stringmetric-a825efe0b41c8a868a2da3024d8cbeb2cf594413.tar.gz stringmetric-a825efe0b41c8a868a2da3024d8cbeb2cf594413.tar.bz2 stringmetric-a825efe0b41c8a868a2da3024d8cbeb2cf594413.zip |
Aliased options type.
Diffstat (limited to 'core')
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala | 8 |
1 files changed, 5 insertions, 3 deletions
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 703b75a..4a2b267 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/similarity/WeightedLevenshteinMetric.scala @@ -5,8 +5,10 @@ import scala.math.BigDecimal /** An implementation of a weighted Levenshtein [[org.hashtree.stringmetric.StringMetric]]. */ object WeightedLevenshteinMetric extends StringMetric with FilterableConfigurableStringMetric[Tuple3[BigDecimal, BigDecimal, BigDecimal]] { + type Options = Tuple3[BigDecimal, BigDecimal, BigDecimal] + /** Options order is delete, insert, then substitute weight. */ - override def compare(charArray1: Array[Char], charArray2: Array[Char])(options: Tuple3[BigDecimal, BigDecimal, BigDecimal]) + override def compare(charArray1: Array[Char], charArray2: Array[Char])(options: Options) (implicit stringFilter: StringFilter): Option[Double] = { val ca1 = stringFilter.filter(charArray1) val ca2 = stringFilter.filter(charArray2) @@ -19,14 +21,14 @@ object WeightedLevenshteinMetric extends StringMetric with FilterableConfigurabl } /** Options order is delete, insert, then substitute weight. */ - override def compare(string1: String, string2: String)(options: Tuple3[BigDecimal, BigDecimal, BigDecimal]) + override def compare(string1: String, string2: String)(options: Options) (implicit stringFilter: StringFilter): Option[Double] = compare( stringFilter.filter(string1.toCharArray), stringFilter.filter(string2.toCharArray) )(options)(new StringFilterDelegate) - private[this] def weightedLevenshtein(ct: CompareTuple[Char], w: Tuple3[BigDecimal, BigDecimal, BigDecimal]) = { + private[this] def weightedLevenshtein(ct: CompareTuple[Char], w: Options) = { val m = Array.ofDim[BigDecimal](ct._1.length + 1, ct._2.length + 1) for (r <- 0 to ct._1.length) m(r)(0) = w._1 * r |