diff options
author | Rocky Madden <git@rockymadden.com> | 2013-03-15 23:59:53 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-03-15 23:59:53 -0600 |
commit | b558d56b50ff1a9fe8023b927fabf1e3d46a8119 (patch) | |
tree | bee888acf7f3f46f5774f340c944ca1a88d21416 /core/source | |
parent | d5f8c6f968c7ad4c086a6ddef526b383648fcffd (diff) | |
download | stringmetric-b558d56b50ff1a9fe8023b927fabf1e3d46a8119.tar.gz stringmetric-b558d56b50ff1a9fe8023b927fabf1e3d46a8119.tar.bz2 stringmetric-b558d56b50ff1a9fe8023b927fabf1e3d46a8119.zip |
Code formatting tweaks.
Diffstat (limited to 'core/source')
5 files changed, 5 insertions, 7 deletions
diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala index f091161..4dd35a7 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetric.scala @@ -20,7 +20,7 @@ class DiceSorensenMetric extends ConfigurableStringMetric[Double, Int] { this: S nGramAlgorithm.compute(fca1)(n).flatMap { ca1bg => nGramAlgorithm.compute(fca2)(n).map { ca2bg => - val ms = scoreMatches((ca1bg.map(_.mkString), ca2bg.map(_.mkString))) + val ms = scoreMatches(ca1bg.map(_.mkString), ca2bg.map(_.mkString)) (2d * ms) / (ca1bg.length + ca2bg.length) } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaccardMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaccardMetric.scala index 91be375..5971701 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaccardMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/JaccardMetric.scala @@ -17,7 +17,7 @@ class JaccardMetric extends ConfigurableStringMetric[Double, Int] { this: String nGramAlgorithm.compute(fca1)(n).flatMap { ca1bg => nGramAlgorithm.compute(fca2)(n).map { ca2bg => - val ms = scoreMatches((ca1bg.map(_.mkString), ca2bg.map(_.mkString))) + val ms = scoreMatches(ca1bg.map(_.mkString), ca2bg.map(_.mkString)) ms.toDouble / (ca1bg.length + ca2bg.length) } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala index 163dd44..d60c218 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetric.scala @@ -25,7 +25,7 @@ class LevenshteinMetric extends StringMetric[Int] { this: StringFilter => case (0, c) => c case (r, c) if m(r)(c) != -1 => m(r)(c) case (r, c) => { - val min = { + val min = if (ct._1(r - 1) == ct._2(c - 1)) distance(r - 1, c - 1) else math.min( math.min( @@ -34,7 +34,6 @@ class LevenshteinMetric extends StringMetric[Int] { this: StringFilter => ), distance(r - 1, c - 1) + 1 // Substitute (left-up). ) - } m(r)(c) = min min diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/OverlapMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/OverlapMetric.scala index 574e131..6927138 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/OverlapMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/OverlapMetric.scala @@ -18,7 +18,7 @@ class OverlapMetric extends ConfigurableStringMetric[Double, Int] { this: String nGramAlgorithm.compute(fca1)(n).flatMap { ca1bg => nGramAlgorithm.compute(fca2)(n).map { ca2bg => - val ms = scoreMatches((ca1bg.map(_.mkString), ca2bg.map(_.mkString))) + val ms = scoreMatches(ca1bg.map(_.mkString), ca2bg.map(_.mkString)) ms.toDouble / (math.min(ca1bg.length, ca2bg.length)) } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala index 8ab3f3a..cac3395 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetric.scala @@ -35,14 +35,13 @@ class WeightedLevenshteinMetric for (c <- 0 to ct._2.length) m(0)(c) = w._2 * c for (r <- 1 to ct._1.length; c <- 1 to ct._2.length) { - m(r)(c) = { + m(r)(c) = if (ct._1(r - 1) == ct._2(c - 1)) m(r - 1)(c - 1) else (m(r - 1)(c) + w._1).min( // Delete (left). (m(r)(c - 1) + w._2).min( // Insert (up). m(r - 1)(c - 1) + w._3 // Substitute (left-up). ) ) - } } m(ct._1.length)(ct._2.length) |