summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRocky Madden <git@rockymadden.com>2012-11-19 20:07:48 -0700
committerRocky Madden <git@rockymadden.com>2012-11-19 20:07:48 -0700
commit8b8ce923a152c9395f4af52ad27104fc5c1c6512 (patch)
tree1b202c7075aaec82459c9dcf3258542771f695f3 /core
parent2df22ead075c51e36a4df8a65ecd6a5282a85460 (diff)
downloadstringmetric-8b8ce923a152c9395f4af52ad27104fc5c1c6512.tar.gz
stringmetric-8b8ce923a152c9395f4af52ad27104fc5c1c6512.tar.bz2
stringmetric-8b8ce923a152c9395f4af52ad27104fc5c1c6512.zip
More idiomatic code.
Diffstat (limited to 'core')
-rwxr-xr-xcore/source/core/scala/org/hashtree/stringmetric/phonetic/Alphabet.scala18
1 files changed, 2 insertions, 16 deletions
diff --git a/core/source/core/scala/org/hashtree/stringmetric/phonetic/Alphabet.scala b/core/source/core/scala/org/hashtree/stringmetric/phonetic/Alphabet.scala
index fd94e75..e6b1c0e 100755
--- a/core/source/core/scala/org/hashtree/stringmetric/phonetic/Alphabet.scala
+++ b/core/source/core/scala/org/hashtree/stringmetric/phonetic/Alphabet.scala
@@ -3,27 +3,13 @@ package org.hashtree.stringmetric.phonetic
import scala.annotation.tailrec
object Alphabet {
- final val SometimesVowels: Set[Char] = Set('a', 'e', 'i', 'o', 'u', 'y')
- final val Vowels: Set[Char] = Set('a', 'e', 'i', 'o', 'u')
-
def is(char: Char): Boolean = (char >= 65 && char <= 90) || (char >= 97 && char <= 122)
- def is(charArray: Array[Char]): Boolean = {
- @tailrec
- def still(ca: Seq[Char]): Boolean =
- if (ca.length == 0) true
- else
- if (!is(ca.head)) false
- else still(ca.tail)
-
- if (charArray.length == 0) false
- else if (charArray.length <= 4) still(charArray)
- else still(charArray.toList)
- }
+ def is(charArray: Array[Char]): Boolean = charArray.length > 0 && !charArray.find(!is(_)).isDefined
def is(string: String): Boolean = is(string.toCharArray)
- def isSometimesVowel(char: Char): Boolean = (char == 'y' || char == 'Y' || isVowel(char))
+ def isSometimesVowel(char: Char): Boolean = char == 'y' || char == 'Y' || isVowel(char)
def isVowel(char: Char): Boolean = (
char == 'a' || char == 'e' || char == 'i' || char == 'o' || char =='u'