diff options
5 files changed, 18 insertions, 18 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala index 7b7f25b..39fe96d 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/MetaphoneAlgorithm.scala @@ -42,7 +42,7 @@ object MetaphoneAlgorithm extends StringAlgorithm with FilterableStringAlgorithm } val t = { - c match { + (c: @switch) match { case 'a' | 'e' | 'i' | 'o' | 'u' => if (l.length == 0) shift(1, o:+ c) else shift(1, o) case 'f' | 'j' | 'l' | 'm' | 'n' | 'r' => shift(1, o :+ c) case 'b' => if (l.length >= 1 && l.last == 'm' && r.length == 0) shift(1, o) else shift(1, o :+ 'b') @@ -100,7 +100,7 @@ object MetaphoneAlgorithm extends StringAlgorithm with FilterableStringAlgorithm case 0 => ca case 1 => if (ca.head == 'x') Array('s') else ca case _ => - ca.head match { + (ca.head: @switch) match { case 'a' if (ca(1) == 'e') => ca.tail case 'g' if (ca(1) == 'n') => ca.tail case 'k' if (ca(1) == 'n') => ca.tail 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 8c1980c..1c6278c 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/NysiisAlgorithm.scala @@ -1,7 +1,7 @@ package org.hashtree.stringmetric.phonetic import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter } -import scala.annotation.tailrec +import scala.annotation.{ switch, tailrec } /** An implementation of the NYSIIS [[org.hashtree.stringmetric.StringAlgorithm]]. */ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { @@ -56,7 +56,7 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { } val t = { - c match { + (c: @switch) match { case 'a' | 'i' | 'o' | 'u' => shift(1, o :+ 'a') case 'b' | 'c' | 'd' | 'f' | 'g' | 'j' | 'l' | 'n' | 'r' | 't' | 'v' | 'x' | 'y' => shift(1, o :+ c) case 'e' => @@ -90,7 +90,7 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { lazy val tr2 = ca.takeRight(ca.length - 2) lazy val tr3 = ca.takeRight(ca.length - 3) - ca.head match { + (ca.head: @switch) match { 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'), tr3) @@ -107,7 +107,7 @@ object NysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { val lcm1 = ca(ca.length - 2) lazy val t2 = ca.take(ca.length - 2) - lc match { + (lc: @switch) match { case 'd' if (lcm1 == 'n' || lcm1 == 'r') => (t2, Array('d')) case 'e' if (lcm1 == 'e' || lcm1 == 'i') => (t2, Array('y')) case 't' if (lcm1 == 'd' || lcm1 == 'n' || lcm1 == 'r') => (t2, Array('d')) 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 4165524..393b24f 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedNysiisAlgorithm.scala @@ -1,7 +1,7 @@ package org.hashtree.stringmetric.phonetic import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter } -import scala.annotation.tailrec +import scala.annotation.{ switch, tailrec } /** An implementation of the refined NYSIIS [[org.hashtree.stringmetric.StringAlgorithm]]. */ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { @@ -53,7 +53,7 @@ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgor } val t = { - c match { + (c: @switch) match { case 'a' | 'i' | 'o' | 'u' => if (l.length == 0) shift(1, o :+ c) else shift(1, o :+ 'a') @@ -100,7 +100,7 @@ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgor private[this] def transcodeHead(ca: Array[Char]) = { if (ca.length == 0) ca else - ca.head match { + (ca.head: @switch) match { case 'm' if (ca.length >= 3 && ca(1) == 'a' && ca(2) == 'c') => Array('m', 'c') ++ ca.takeRight(ca.length - 3) case 'p' if (ca.length >= 2 && ca(1) == 'f') => 'f' +: ca.takeRight(ca.length - 2) case _ => ca @@ -113,7 +113,7 @@ object RefinedNysiisAlgorithm extends StringAlgorithm with FilterableStringAlgor val lcm1 = ca(ca.length - 2) lazy val t2 = ca.take(ca.length - 2) - lc match { + (lc: @switch) match { case 'd' if (lcm1 == 'n' || lcm1 == 'r') => t2 :+ 'd' case 'e' if (lcm1 == 'e' || lcm1 == 'i' || lcm1 =='y') => t2 :+ 'y' case 't' if (lcm1 == 'd' || lcm1 == 'n' || lcm1 == 'r') => t2 :+ 'd' 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 43075a1..f7d2cc1 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexAlgorithm.scala @@ -1,7 +1,7 @@ package org.hashtree.stringmetric.phonetic import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter } -import scala.annotation.tailrec +import scala.annotation.{ switch, tailrec } /** An implementation of the refined Soundex [[org.hashtree.stringmetric.StringAlgorithm]]. */ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { @@ -22,7 +22,7 @@ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgo if (i.length == 0) o else { val c = i.head.toLower - val m2 = (mc: Char) => mc match { + val m2 = (mc: Char) => (mc: @switch) match { case 'a' | 'e' | 'h' | 'i' | 'o' | 'u' | 'w' | 'y' => '0' case 'b' | 'p' => '1' case 'f' | 'v' => '2' @@ -35,7 +35,7 @@ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgo case 'r' => '9' case _ => '\0' } - val m1 = (mc: Char, pc: Char) => mc match { + val m1 = (mc: Char, pc: Char) => (mc: @switch) match { case 'a' | 'e' | 'h' | 'i' | 'o' | 'u' | 'w' | 'y' if pc != '0' => '0' case 'b' | 'p' if pc != '1' => '1' case 'f' | 'v' if pc != '2' => '2' @@ -54,7 +54,7 @@ object RefinedSoundexAlgorithm extends StringAlgorithm with FilterableStringAlgo // Code once. else m1( c, - o.last match { + (o.last: @switch) match { case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => o.last case _ => m2(o.last) } diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala index c5f6174..4a41cc9 100755 --- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala +++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/SoundexAlgorithm.scala @@ -1,7 +1,7 @@ package org.hashtree.stringmetric.phonetic import org.hashtree.stringmetric.{ FilterableStringAlgorithm, StringAlgorithm, StringFilter } -import scala.annotation.tailrec +import scala.annotation.{ switch, tailrec } /** An implementation of the Soundex [[org.hashtree.stringmetric.StringAlgorithm]]. */ object SoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { @@ -26,7 +26,7 @@ object SoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { if (i.length == 0) o else { val c = i.head.toLower - val m2 = (mc: Char) => mc match { + val m2 = (mc: Char) => (mc: @switch) match { case 'b' | 'f' | 'p' | 'v' => '1' case 'c' | 'g' | 'j' | 'k' | 'q' | 's' | 'x' | 'z' => '2' case 'd' | 't' => '3' @@ -35,7 +35,7 @@ object SoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { case 'r' => '6' case _ => '\0' } - val m1 = (mc: Char, pc: Char) => mc match { + val m1 = (mc: Char, pc: Char) => (mc: @switch) match { case 'b' | 'f' | 'p' | 'v' if pc != '1' => '1' case 'c' | 'g' | 'j' | 'k' | 'q' | 's' | 'x' | 'z' if pc != '2' => '2' case 'd' | 't' if pc != '3' => '3' @@ -50,7 +50,7 @@ object SoundexAlgorithm extends StringAlgorithm with FilterableStringAlgorithm { // Code once. case _ => m1( c, - o.last match { + (o.last: @switch) match { case '1' | '2' | '3' | '4' | '5' | '6' => o.last case _ => m2(o.last) } |