diff options
author | Rocky Madden <git@rockymadden.com> | 2012-10-09 02:52:10 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-10-09 02:52:10 -0600 |
commit | 4d7d0666ebcf061d87a9516d5ad338836ffb273d (patch) | |
tree | 088d07804e2449cbb0b3a3308ac697ec9fb983bb /core | |
parent | 54ad77aa5ebbf488a459efa5aa8b586b7003167b (diff) | |
download | stringmetric-4d7d0666ebcf061d87a9516d5ad338836ffb273d.tar.gz stringmetric-4d7d0666ebcf061d87a9516d5ad338836ffb273d.tar.bz2 stringmetric-4d7d0666ebcf061d87a9516d5ad338836ffb273d.zip |
Fixed commenting width.
Diffstat (limited to 'core')
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala | 11 | ||||
-rwxr-xr-x | core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala | 10 |
2 files changed, 11 insertions, 10 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala index c1b21b1..cd1a168 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/JaroMetric.scala @@ -5,29 +5,30 @@ import scala.math import scala.util.control.Breaks.{ break, breakable } /** - * An implementation of the Jaro [[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. + * An implementation of the Jaro [[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. */ object JaroMetric extends StringMetric { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Float = { val ca1 = stringCleaner.clean(charArray1) val ca2 = stringCleaner.clean(charArray2) - // Return 0f if either character array lacks length. + // Return 0 if either character array lacks length. if (ca1.length == 0 || ca2.length == 0) return 0f val mt = `match`((ca1, ca2)) val ms = scoreMatches((mt._1, mt._2)) val ts = scoreTranspositions((mt._1, mt._2)) - // Return 0f if matches score is 0. + // Return 0 if matches score is 0. if (ms == 0) return 0f ((ms.toFloat / ca1.length) + (ms.toFloat / ca2.length) + ((ms.toFloat - ts) / ms)) / 3 } override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Float = { - // Return 1f if strings are an exact match. + // Return 1 if strings are an exact match. if (string1.length > 0 && string2.length > 0 && string1 == string2) return 1f compare(stringCleaner.clean(string1.toCharArray), stringCleaner.clean(string2.toCharArray))(new StringCleanerDelegate) diff --git a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala index c12a3ee..f21cc54 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/JaroWinklerMetric.scala @@ -1,9 +1,9 @@ package org.hashtree.stringmetric /** - * 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). + * 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 { override def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit stringCleaner: StringCleaner): Float = { @@ -12,11 +12,11 @@ object JaroWinklerMetric extends StringMetric { val jaro = JaroMetric.compare(ca1, ca2)(new StringCleanerDelegate) val prefix = ca1.zip(ca2).takeWhile(t => t._1 == t._2).map(_._1) - jaro + ((if (prefix.length <= 4) prefix.length else 4) * (0.1f * (1 - jaro))) + jaro + ((if (prefix.length <= 4) prefix.length else 4) * 0.1f * (1 - jaro)) } override def compare(string1: String, string2: String)(implicit stringCleaner: StringCleaner): Float = { - // Return 1f if strings are an exact match. + // Return 1 if strings are an exact match. if (string1.length > 0 && string2.length > 0 && string1 == string2) return 1f compare(stringCleaner.clean(string1.toCharArray), stringCleaner.clean(string2.toCharArray))(new StringCleanerDelegate) |