summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-11-18 19:43:37 -0700
committerRocky Madden <git@rockymadden.com>2012-11-18 19:43:37 -0700
commit4ad78c7c71f0c08cf848e8c5f345355f40f337a5 (patch)
tree97a22d72b31605cf722e1341b9b6d1ffdbfd6605
parent51a58aa5d93c54502e1d640fa02339bf88c399b5 (diff)
downloadstringmetric-4ad78c7c71f0c08cf848e8c5f345355f40f337a5.tar.gz
stringmetric-4ad78c7c71f0c08cf848e8c5f345355f40f337a5.tar.bz2
stringmetric-4ad78c7c71f0c08cf848e8c5f345355f40f337a5.zip
Shortened variable names.
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala23
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala15
2 files changed, 18 insertions, 20 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala
index eb2b2f5..eaf3872 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala
@@ -47,8 +47,7 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm {
private[this] def deduplicate(ca: Array[Char]) =
if (ca.length <= 1) ca
- else
- ca.sliding(2).withFilter(a => a(0) != a(1)).map(a => a(0)).toArray[Char] :+ ca.last
+ else ca.sliding(2).withFilter(a => a(0) != a(1)).map(a => a(0)).toArray[Char] :+ ca.last
@tailrec
private[this] def transcodeCenter(l: Array[Char], c: Char, r: Array[Char], o: Array[Char]): Array[Char] = {
@@ -96,15 +95,15 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm {
private[this] def transcodeLeft(ca: Array[Char]) = {
if (ca.length == 0) (Array.empty[Char], ca)
else {
- lazy val takeRight2 = ca.takeRight(ca.length - 2)
- lazy val takeRight3 = ca.takeRight(ca.length - 3)
+ lazy val tr2 = ca.takeRight(ca.length - 2)
+ lazy val tr3 = ca.takeRight(ca.length - 3)
ca.head match {
- case 'k' if (ca.length >= 2 && ca(1) == 'n') => (Array('n', 'n'), takeRight2)
+ case 'k' if (ca.length >= 2 && ca(1) == 'n') => (Array('n', 'n'), tr2)
case 'k' => (Array('c'), ca.tail)
- case 'm' if (ca.length >= 3 && (ca(1) == 'a' && ca(2) == 'c')) => (Array('m', 'c'), takeRight3)
- case 'p' if (ca.length >= 2 && (ca(1) == 'h' || ca(1) == 'f')) => (Array('f', 'f'), takeRight2)
- case 's' if (ca.length >= 3 && (ca(1) == 'c' && ca(2) == 'h')) => (Array('s', 's'), takeRight3)
+ case 'm' if (ca.length >= 3 && (ca(1) == 'a' && ca(2) == 'c')) => (Array('m', 'c'), tr3)
+ case 'p' if (ca.length >= 2 && (ca(1) == 'h' || ca(1) == 'f')) => (Array('f', 'f'), tr2)
+ case 's' if (ca.length >= 3 && (ca(1) == 'c' && ca(2) == 'h')) => (Array('s', 's'), tr3)
case _ => (Array(ca.head), ca.tail)
}
}
@@ -114,12 +113,12 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm {
if (ca.length >= 2) {
val l = ca(ca.length - 1)
val lm1 = ca(ca.length - 2)
- lazy val take2 = ca.take(ca.length - 2)
+ lazy val t2 = ca.take(ca.length - 2)
l match {
- case 'd' if (lm1 == 'n' || lm1 == 'r') => (take2, Array('d'))
- case 'e' if (lm1 == 'e' || lm1 == 'i') => (take2, Array('y'))
- case 't' if (lm1 == 'd' || lm1 == 'n' || lm1 == 'r') => (take2, Array('d'))
+ case 'd' if (lm1 == 'n' || lm1 == 'r') => (t2, Array('d'))
+ case 'e' if (lm1 == 'e' || lm1 == 'i') => (t2, Array('y'))
+ case 't' if (lm1 == 'd' || lm1 == 'n' || lm1 == 'r') => (t2, Array('d'))
case _ => (ca, Array.empty[Char])
}
} else (ca, Array.empty[Char])
diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala
index bbb55d0..571b002 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala
@@ -43,8 +43,7 @@ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgor
private[this] def deduplicate(ca: Array[Char]) =
if (ca.length <= 1) ca
- else
- ca.sliding(2).withFilter(a => a(0) != a(1)).map(a => a(0)).toArray[Char] :+ ca.last
+ else ca.sliding(2).withFilter(a => a(0) != a(1)).map(a => a(0)).toArray[Char] :+ ca.last
@tailrec
private[this] def transcode(l: Array[Char], c: Char, r: Array[Char], o: Array[Char]): Array[Char] = {
@@ -120,14 +119,14 @@ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgor
if (ca.length >= 2) {
val l = ca(ca.length - 1)
val lm1 = ca(ca.length - 2)
- lazy val take2 = ca.take(ca.length - 2)
+ lazy val t2 = ca.take(ca.length - 2)
l match {
- case 'd' if (lm1 == 'n' || lm1 == 'r') => take2 :+ 'd'
- case 'e' if (lm1 == 'e' || lm1 == 'i' || lm1 =='y') => take2 :+ 'y'
- case 't' if (lm1 == 'd' || lm1 == 'n' || lm1 == 'r') => take2 :+ 'd'
- case 'x' if (lm1 == 'e') => take2 ++ Array('e', 'c')
- case 'x' if (lm1 == 'i') => take2 ++ Array('i', 'c')
+ case 'd' if (lm1 == 'n' || lm1 == 'r') => t2 :+ 'd'
+ case 'e' if (lm1 == 'e' || lm1 == 'i' || lm1 =='y') => t2 :+ 'y'
+ case 't' if (lm1 == 'd' || lm1 == 'n' || lm1 == 'r') => t2 :+ 'd'
+ case 'x' if (lm1 == 'e') => t2 ++ Array('e', 'c')
+ case 'x' if (lm1 == 'i') => t2 ++ Array('i', 'c')
case _ => ca
}
} else ca