summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-11-21 09:11:45 -0700
committerRocky Madden <git@rockymadden.com>2012-11-21 09:11:45 -0700
commit7b63d94dbf2336574ee92f387e2649f5f17193ab (patch)
tree5102d32351dfe1d67b612efc0189fd44518bdfaa
parent11a858e84ae72be76ce6ebb9d5730bb152fa35f2 (diff)
downloadstringmetric-7b63d94dbf2336574ee92f387e2649f5f17193ab.tar.gz
stringmetric-7b63d94dbf2336574ee92f387e2649f5f17193ab.tar.bz2
stringmetric-7b63d94dbf2336574ee92f387e2649f5f17193ab.zip
Fixed bug where previous character was being passed around when it wasn't being used.
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala10
1 files changed, 3 insertions, 7 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala
index 878cf5c..8d58885 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala
@@ -12,18 +12,14 @@ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgo
val ca = stringFilter.filter(charArray)
if (ca.length == 0 || !Alphabet.is(ca.head)) None
- else {
- val fc = ca.head.toLower
-
- Some(transcode(ca, fc, Array(fc)))
- }
+ else Some(transcode(ca, Array(ca.head.toLower)))
}
override def compute(string: String)(implicit stringFilter: StringFilter): Option[ComputeReturn] =
compute(stringFilter.filter(string.toCharArray))(new StringFilterDelegate).map(_.mkString)
@tailrec
- private[this] def transcode(i: Array[Char], p: Char, o: Array[Char]): Array[Char] = {
+ private[this] def transcode(i: Array[Char], o: Array[Char]): Array[Char] = {
require(o.length > 0)
if (i.length == 0) o
@@ -67,7 +63,7 @@ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgo
}
)
- transcode(i.tail, c, if (a != '\0') o :+ a else o)
+ transcode(i.tail, if (a != '\0') o :+ a else o)
}
}
} \ No newline at end of file