summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-10-20 15:11:32 -0600
committerRocky Madden <git@rockymadden.com>2012-10-20 15:11:32 -0600
commit0d6679e72d7dd284ab3edeeb7f1e1ae109cdacc9 (patch)
treec141f490410b938eb91004ad45fd5a0951b8d469 /core
parentf9ceaad11b584dffcd360bba7893dd4bbf4047bd (diff)
downloadstringmetric-0d6679e72d7dd284ab3edeeb7f1e1ae109cdacc9.tar.gz
stringmetric-0d6679e72d7dd284ab3edeeb7f1e1ae109cdacc9.tar.bz2
stringmetric-0d6679e72d7dd284ab3edeeb7f1e1ae109cdacc9.zip
Added type to CompareTuple and MatchTuple types.
Diffstat (limited to 'core')
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala6
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala2
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/package.scala4
4 files changed, 7 insertions, 7 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala
index f8fe982..657c818 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/distance/HammingMetric.scala
@@ -21,7 +21,7 @@ object HammingMetric extends StringMetric {
)(new StringCleanerDelegate)
}
- private[this] def hamming(ct: CompareTuple) = {
+ private[this] def hamming(ct: CompareTuple[Char]) = {
require(ct._1.length > 0)
require(ct._2.length > 0)
require(ct._1.length == ct._2.length)
diff --git a/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala
index 6309bc5..32315d8 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/distance/JaroMetric.scala
@@ -36,7 +36,7 @@ object JaroMetric extends StringMetric {
)(new StringCleanerDelegate)
}
- private[this] def `match`(ct: CompareTuple) = {
+ private[this] def `match`(ct: CompareTuple[Char]) = {
val window = math.abs((math.max(ct._1.length, ct._2.length) / 2f).floor.toInt - 1)
val one = ArrayBuffer[Int]()
val two = HashSet[Int]()
@@ -67,13 +67,13 @@ object JaroMetric extends StringMetric {
(one.toArray.map(ct._1(_)), two.toArray.sortWith(_ < _).map(ct._2(_)))
}
- private[this] def scoreMatches(mt: MatchTuple) = {
+ private[this] def scoreMatches(mt: MatchTuple[Char]) = {
require(mt._1.length == mt._2.length)
mt._1.length
}
- private[this] def scoreTranspositions(mt: MatchTuple) = {
+ private[this] def scoreTranspositions(mt: MatchTuple[Char]) = {
require(mt._1.length == mt._2.length)
(mt._1.zip(mt._2).filter(t => t._1 != t._2).length / 2f).floor.toInt
diff --git a/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala
index 9925b57..ab22bac 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/distance/LevenshteinMetric.scala
@@ -24,7 +24,7 @@ object LevenshteinMetric extends StringMetric {
)(new StringCleanerDelegate)
}
- private[this] def levenshtein(f: CompareTuple => Int)(ct: CompareTuple): Int = {
+ private[this] def levenshtein(f: CompareTuple[Char] => Int)(ct: CompareTuple[Char]): Int = {
if (ct._1.length == 0)
ct._2.length
else if (ct._2.length == 0)
diff --git a/core/source/core/scala/org/hashtree/stringmetric/package.scala b/core/source/core/scala/org/hashtree/stringmetric/package.scala
index 89bfee4..6c842ba 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/package.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/package.scala
@@ -2,9 +2,9 @@ package org.hashtree
/** Provides core string metric functionality. */
package object stringmetric {
- type CompareTuple = Tuple2[Array[Char], Array[Char]]
+ type CompareTuple[T] = Tuple2[Array[T], Array[T]]
- type MatchTuple = CompareTuple
+ type MatchTuple[T] = Tuple2[Array[T], Array[T]]
implicit val stringCleaner = new StringCleanerDelegate
} \ No newline at end of file