summaryrefslogtreecommitdiff
path: root/stringmetric-core/source/test
diff options
context:
space:
mode:
Diffstat (limited to 'stringmetric-core/source/test')
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala96
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala38
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/ScalaTest.scala18
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala59
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala141
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala23
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala29
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala35
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala37
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala31
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala33
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala41
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala31
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala226
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala54
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala204
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala50
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala221
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala50
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala175
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala50
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala174
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala50
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala75
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala52
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala77
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala66
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala66
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala65
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala75
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala77
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala56
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala64
-rwxr-xr-xstringmetric-core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala69
40 files changed, 2806 insertions, 0 deletions
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala
new file mode 100755
index 0000000..5bb503a
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/AlphabetSpec.scala
@@ -0,0 +1,96 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.Alphabet.{Alpha, Vowel}
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AlphabetSpec extends ScalaTest {
+ "Alphabet" should provide {
+ "an overloaded isSuperset method which accepts Char" when passed {
+ "non-alphabet argument" should returns {
+ "false" in {
+ Alpha isSuperset '0' should be (false)
+ }
+ }
+ "alphabet argument" should returns {
+ "true" in {
+ Alpha isSuperset 'a' should be (true)
+ Alpha isSuperset 'A' should be (true)
+ }
+ }
+ "non-vowel argument" should returns {
+ "false" in {
+ Vowel isSuperset 'y' should be (false)
+ }
+ }
+ "vowel argument" should returns {
+ "true" in {
+ Vowel isSuperset 'a' should be (true)
+ Vowel isSuperset 'A' should be (true)
+ }
+ }
+ }
+ "an overloaded isSuperset method which accepts Array[Char]" when passed {
+ "empty argument" should returns {
+ "false" in {
+ Alpha isSuperset Array.empty[Char] should be (false)
+ }
+ }
+ "non-alphabet argument" should returns {
+ "false" in {
+ Alpha isSuperset "hi!".toCharArray should be (false)
+ Alpha isSuperset "helloworld!".toCharArray should be (false)
+ }
+ }
+ "alphabet argument" should returns {
+ "true" in {
+ Alpha isSuperset "hi".toCharArray should be (true)
+ Alpha isSuperset "helloworld".toCharArray should be (true)
+ Alpha isSuperset "HI".toCharArray should be (true)
+ Alpha isSuperset "HELLOWORLD".toCharArray should be (true)
+ }
+ }
+ "non-vowel argument" should returns {
+ "false" in {
+ Vowel isSuperset "y".toCharArray should be (false)
+ }
+ }
+ "vowel argument" should returns {
+ "true" in {
+ Vowel isSuperset "a".toCharArray should be (true)
+ Vowel isSuperset "A".toCharArray should be (true)
+ }
+ }
+ }
+ "an overloaded isSuperset method which accepts String" when passed {
+ "empty argument" should returns {
+ "false" in {
+ Alpha isSuperset "" should be (false)
+ }
+ }
+ "non-alphabet argument" should returns {
+ "false" in {
+ Alpha isSuperset "helloworld!" should be (false)
+ }
+ }
+ "alphabet argument" should returns {
+ "true" in {
+ Alpha isSuperset "helloworld" should be (true)
+ Alpha isSuperset "HELLOWORLD" should be (true)
+ }
+ }
+ "non-vowel argument" should returns {
+ "false" in {
+ Vowel isSuperset "y" should be (false)
+ }
+ }
+ "vowel argument" should returns {
+ "true" in {
+ Vowel isSuperset "a" should be (true)
+ Vowel isSuperset "A" should be (true)
+ }
+ }
+ }
+ }
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala
new file mode 100755
index 0000000..e900f83
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala
@@ -0,0 +1,38 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.filter.AsciiNumberFilter
+import com.rockymadden.stringmetric.phonetic.MetaphoneAlgorithm
+import com.rockymadden.stringmetric.similarity.DiceSorensenMetric
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class FilterDecoratedSpec extends ScalaTest {
+ import FilterDecoratedSpec.{Algorithm, Metric}
+
+ "Filter decorated metrics" should provide {
+ "compare method" when passed {
+ "filterable arguments" should returns {
+ "filtered results" in {
+ Metric.compare("123", "456")(1).isDefined should be (false)
+ Metric.compare("ni123ght", "na456cht")(1).get should be (0.6)
+ }
+ }
+ }
+ }
+ "Filter decorated algorithms" should provide {
+ "compute method" when passed {
+ "filterable argument" should returns {
+ "filtered results" in {
+ Algorithm.compute("456").isDefined should be (false)
+ Algorithm.compute("du123mb456").get should equal ("tm")
+ }
+ }
+ }
+ }
+}
+
+object FilterDecoratedSpec {
+ private final val Algorithm = new MetaphoneAlgorithm with AsciiNumberFilter
+ private final val Metric = new DiceSorensenMetric with AsciiNumberFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/ScalaTest.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/ScalaTest.scala
new file mode 100755
index 0000000..5f4ab62
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/ScalaTest.scala
@@ -0,0 +1,18 @@
+package com.rockymadden.stringmetric
+
+import org.scalatest.{BeforeAndAfter, ParallelTestExecution, WordSpec}
+import org.scalatest.matchers.ShouldMatchers
+
+trait ScalaTest extends WordSpec with ShouldMatchers with BeforeAndAfter with ParallelTestExecution {
+ def allows = afterWord("allow")
+
+ def executes = afterWord("execute")
+
+ def passed = afterWord("passed")
+
+ def provide = afterWord("provide")
+
+ def returns = afterWord("return")
+
+ def throws = afterWord("throw")
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala
new file mode 100755
index 0000000..7ce0c24
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala
@@ -0,0 +1,59 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.phonetic._
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class StringAlgorithmSpec extends ScalaTest {
+ "StringAlgorithm standalone object" should provide {
+ "compute method, type, and companion object pass-throughs" in {
+ val metaphone: StringAlgorithm.Metaphone = StringAlgorithm.Metaphone()
+
+ metaphone.compute("testone").get should
+ equal (StringAlgorithm.computeWithMetaphone("testone").get)
+ metaphone.compute("testone".toCharArray).get should
+ equal (StringAlgorithm.computeWithMetaphone("testone".toCharArray).get)
+ metaphone.compute("testone".toCharArray).get should
+ equal (MetaphoneAlgorithm.compute("testone".toCharArray).get)
+
+ val nysiis: StringAlgorithm.Nysiis = StringAlgorithm.Nysiis()
+
+ nysiis.compute("testone").get should
+ equal (StringAlgorithm.computeWithNysiis("testone").get)
+ nysiis.compute("testone".toCharArray).get should
+ equal (StringAlgorithm.computeWithNysiis("testone".toCharArray).get)
+ nysiis.compute("testone".toCharArray).get should
+ equal (NysiisAlgorithm.compute("testone".toCharArray).get)
+
+ val refinedNysiis: StringAlgorithm.RefinedNysiis = StringAlgorithm.RefinedNysiis()
+
+ refinedNysiis.compute("testone").get should
+ equal (StringAlgorithm.computeWithRefinedNysiis("testone").get)
+ refinedNysiis.compute("testone".toCharArray).get should
+ equal (StringAlgorithm.computeWithRefinedNysiis("testone".toCharArray).get)
+ refinedNysiis.compute("testone".toCharArray).get should
+ equal (RefinedNysiisAlgorithm.compute("testone".toCharArray).get)
+
+ val refinedSoundex: StringAlgorithm.RefinedSoundex = StringAlgorithm.RefinedSoundex()
+
+ refinedSoundex.compute("testone").get should
+ equal (StringAlgorithm.computeWithRefinedSoundex("testone").get)
+ refinedSoundex.compute("testone".toCharArray).get should
+ equal (StringAlgorithm.computeWithRefinedSoundex("testone".toCharArray).get)
+ refinedSoundex.compute("testone".toCharArray).get should
+ equal (RefinedSoundexAlgorithm.compute("testone".toCharArray).get)
+
+ val soundex: StringAlgorithm.Soundex = StringAlgorithm.Soundex()
+
+ soundex.compute("testone").get should
+ equal (StringAlgorithm.computeWithSoundex("testone").get)
+ soundex.compute("testone".toCharArray).get should
+ equal (StringAlgorithm.computeWithSoundex("testone".toCharArray).get)
+ soundex.compute("testone".toCharArray).get should
+ equal (SoundexAlgorithm.compute("testone".toCharArray).get)
+ }
+ }
+}
+
+
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala
new file mode 100755
index 0000000..ca99bff
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala
@@ -0,0 +1,141 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.phonetic._
+import com.rockymadden.stringmetric.similarity._
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class StringMetricSpec extends ScalaTest {
+ "StringMetric standalone object" should provide {
+ "compare method, type, and companion object pass-throughs" in {
+ val diceSorensen: StringMetric.DiceSorensen = StringMetric.DiceSorensen()
+
+ diceSorensen.compare("testone", "testtwo")(1).get should
+ equal (StringMetric.compareWithDiceSorensen("testone", "testtwo")(1).get)
+ diceSorensen.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (StringMetric.compareWithDiceSorensen("testone".toCharArray, "testtwo".toCharArray)(1).get)
+ diceSorensen.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (DiceSorensenMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get)
+
+ val hamming: StringMetric.Hamming = StringMetric.Hamming()
+
+ hamming.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithHamming("testone", "testtwo").get)
+ hamming.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithHamming("testone".toCharArray, "testtwo".toCharArray).get)
+ hamming.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (HammingMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val jaccard: StringMetric.Jaccard = StringMetric.Jaccard()
+
+ jaccard.compare("testone", "testtwo")(1).get should
+ equal (StringMetric.compareWithJaccard("testone", "testtwo")(1).get)
+ jaccard.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (StringMetric.compareWithJaccard("testone".toCharArray, "testtwo".toCharArray)(1).get)
+ jaccard.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (JaccardMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get)
+
+ val jaro: StringMetric.Jaro = StringMetric.Jaro()
+
+ jaro.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithJaro("testone", "testtwo").get)
+ jaro.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithJaro("testone".toCharArray, "testtwo".toCharArray).get)
+ jaro.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (JaroMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val jaroWinkler: StringMetric.JaroWinkler = StringMetric.JaroWinkler()
+
+ jaroWinkler.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithJaroWinkler("testone", "testtwo").get)
+ jaroWinkler.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithJaroWinkler("testone".toCharArray, "testtwo".toCharArray).get)
+ jaroWinkler.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (JaroWinklerMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val levenshtein: StringMetric.Levenshtein = StringMetric.Levenshtein()
+
+ levenshtein.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithLevenshtein("testone", "testtwo").get)
+ levenshtein.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithLevenshtein("testone".toCharArray, "testtwo".toCharArray).get)
+ levenshtein.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (LevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val metaphone: StringMetric.Metaphone = StringMetric.Metaphone()
+
+ metaphone.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithMetaphone("testone", "testtwo").get)
+ metaphone.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithMetaphone("testone".toCharArray, "testtwo".toCharArray).get)
+ metaphone.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (MetaphoneMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val nGram: StringMetric.NGram = StringMetric.NGram()
+
+ nGram.compare("testone", "testtwo")(1).get should
+ equal (StringMetric.compareWithNGram("testone", "testtwo")(1).get)
+ nGram.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (StringMetric.compareWithNGram("testone".toCharArray, "testtwo".toCharArray)(1).get)
+ nGram.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (NGramMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get)
+
+ val nysiis: StringMetric.Nysiis = StringMetric.Nysiis()
+
+ nysiis.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithNysiis("testone", "testtwo").get)
+ nysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithNysiis("testone".toCharArray, "testtwo".toCharArray).get)
+ nysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (NysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val overlap: StringMetric.Overlap = StringMetric.Overlap()
+
+ overlap.compare("testone", "testtwo")(1).get should
+ equal (StringMetric.compareWithOverlap("testone", "testtwo")(1).get)
+ overlap.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (StringMetric.compareWithOverlap("testone".toCharArray, "testtwo".toCharArray)(1).get)
+ overlap.compare("testone".toCharArray, "testtwo".toCharArray)(1).get should
+ equal (OverlapMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1).get)
+
+ val refinedNysiis: StringMetric.RefinedNysiis = StringMetric.RefinedNysiis()
+
+ refinedNysiis.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithRefinedNysiis("testone", "testtwo").get)
+ refinedNysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithRefinedNysiis("testone".toCharArray, "testtwo".toCharArray).get)
+ refinedNysiis.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (RefinedNysiisMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val refinedSoundex: StringMetric.RefinedSoundex = StringMetric.RefinedSoundex()
+
+ refinedSoundex.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithRefinedSoundex("testone", "testtwo").get)
+ refinedSoundex.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithRefinedSoundex("testone".toCharArray, "testtwo".toCharArray).get)
+ refinedSoundex.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (RefinedSoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val soundex: StringMetric.Soundex = StringMetric.Soundex()
+
+ soundex.compare("testone", "testtwo").get should
+ equal (StringMetric.compareWithSoundex("testone", "testtwo").get)
+ soundex.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (StringMetric.compareWithSoundex("testone".toCharArray, "testtwo".toCharArray).get)
+ soundex.compare("testone".toCharArray, "testtwo".toCharArray).get should
+ equal (SoundexMetric.compare("testone".toCharArray, "testtwo".toCharArray).get)
+
+ val weightedLevenshtein: StringMetric.WeightedLevenshtein = StringMetric.WeightedLevenshtein()
+
+ weightedLevenshtein.compare("testone", "testtwo")(1, 2, 3).get should
+ equal (StringMetric.compareWithWeightedLevenshtein("testone", "testtwo")(1, 2, 3).get)
+ weightedLevenshtein.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get should
+ equal (StringMetric.compareWithWeightedLevenshtein("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get)
+ weightedLevenshtein.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get should
+ equal (WeightedLevenshteinMetric.compare("testone".toCharArray, "testtwo".toCharArray)(1, 2, 3).get)
+ }
+ }
+}
+
+
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala
new file mode 100755
index 0000000..8837c25
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala
@@ -0,0 +1,23 @@
+package com.rockymadden.stringmetric
+
+import com.rockymadden.stringmetric.tokenization.NGramTokenizer
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class StringTokenizerSpec extends ScalaTest {
+ "StringTokenizer standalone object" should provide {
+ "tokenize method, type, and companion object pass-throughs" in {
+ val nGram: StringTokenizer.NGram = StringTokenizer.NGram()
+
+ nGram.tokenize("testone")(1).get should
+ equal (StringTokenizer.tokenizeWithNGram("testone")(1).get)
+ nGram.tokenize("testone".toCharArray)(1).get should
+ equal (StringTokenizer.tokenizeWithNGram("testone".toCharArray)(1).get)
+ nGram.tokenize("testone".toCharArray)(1).get should
+ equal (NGramTokenizer.tokenize("testone".toCharArray)(1).get)
+ }
+ }
+}
+
+
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala
new file mode 100755
index 0000000..1cce0c9
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiControlFilterSpec extends ScalaTest {
+ import AsciiControlFilterSpec.Filter
+
+ "AsciiControlFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with controls" should returns {
+ "String with controls removed" in {
+ Filter.filter(" HelloWorld") should equal ("HelloWorld")
+ Filter.filter("HelloWorld ") should equal ("HelloWorld")
+ Filter.filter("Hello World") should equal ("HelloWorld")
+ }
+ }
+ "character array with controls" should returns {
+ "character array with controls removed" in {
+ Filter.filter(" HelloWorld".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("HelloWorld ".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("Hello World".toCharArray) should equal ("HelloWorld".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiControlFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiControlFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala
new file mode 100755
index 0000000..958c8ba
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiControlOnlyFilterSpec extends ScalaTest {
+ import AsciiControlOnlyFilterSpec.Filter
+
+ "AsciiControlOnlyFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed characters" should returns {
+ "String with non-controls removed" in {
+ Filter.filter("!@#$% ^&*()abc") should equal (" ")
+ Filter.filter(" ^&*()abc") should equal (" ")
+ Filter.filter("%^&*()abc ") should equal (" ")
+ }
+ }
+ "character array with mixed characters" should returns {
+ "character array with non-controls removed" in {
+ Filter.filter("!@#$% ^&*()abc".toCharArray) should equal (" ".toCharArray)
+ Filter.filter(" ^&*()abc".toCharArray) should equal (" ".toCharArray)
+ Filter.filter("%^&*()abc ".toCharArray) should equal (" ".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiControlOnlyFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiControlOnlyFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala
new file mode 100755
index 0000000..d86e7a5
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala
@@ -0,0 +1,29 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiLetterFilterSpec extends ScalaTest {
+ import AsciiLetterFilterSpec.Filter
+
+ "AsciiLetterFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with letters" should returns {
+ "String with letters removed" in {
+ Filter.filter(" Hello123World!") should equal (" 123!")
+ }
+ }
+ "character array with letters" should returns {
+ "character array with letters removed" in {
+ Filter.filter(" Hello123World!".toCharArray) should equal (" 123!".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiLetterFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiLetterFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala
new file mode 100755
index 0000000..edfdce6
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiLetterNumberFilterSpec extends ScalaTest {
+ import AsciiLetterNumberFilterSpec.Filter
+
+ "AsciiLetterNumberFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with letters and numbers" should returns {
+ "String with letters and numbers removed" in {
+ Filter.filter(" Hello123World!") should equal (" !")
+ Filter.filter("Hello123 !World") should equal (" !")
+ Filter.filter("!Hello123World ") should equal ("! ")
+ }
+ }
+ "character array with letters and numbers" should returns {
+ "character array with letters and numbers removed" in {
+ Filter.filter(" Hello123World!".toCharArray) should equal (" !".toCharArray)
+ Filter.filter("Hello123 !World".toCharArray) should equal (" !".toCharArray)
+ Filter.filter("!Hello123World ".toCharArray) should equal ("! ".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiLetterNumberFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiLetterNumberFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala
new file mode 100755
index 0000000..7998e39
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala
@@ -0,0 +1,35 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiLetterNumberOnlyFilterSpec extends ScalaTest {
+ import AsciiLetterNumberOnlyFilterSpec.Filter
+
+ "AsciiLetterNumberOnlyFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed characters" should returns {
+ "String with non-letters and non-numbers removed" in {
+ Filter.filter("!@#$%^&*()abc") should equal ("abc")
+ Filter.filter("!@#$%^&*()abc123") should equal ("abc123")
+ Filter.filter("abc123!@#$%^&*()") should equal ("abc123")
+ Filter.filter("!@#$%abc123^&*()") should equal ("abc123")
+ }
+ }
+ "character array with mixed characters" should returns {
+ "character array with non-letters and non-numbers removed" in {
+ Filter.filter("!@#$%^&*()abc".toCharArray) should equal ("abc".toCharArray)
+ Filter.filter("!@#$%^&*()abc123".toCharArray) should equal ("abc123".toCharArray)
+ Filter.filter("abc123!@#$%^&*()".toCharArray) should equal ("abc123".toCharArray)
+ Filter.filter("!@#$%abc123^&*()".toCharArray) should equal ("abc123".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiLetterNumberOnlyFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiLetterNumberOnlyFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala
new file mode 100755
index 0000000..d134792
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiLetterOnlyFilterSpec extends ScalaTest {
+ import AsciiLetterOnlyFilterSpec.Filter
+
+ "AsciiLetterOnlyFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed characters" should returns {
+ "String with non-letters removed" in {
+ Filter.filter("!@#$%^&*()abc") should equal ("abc")
+ Filter.filter("!@#$%^&*()abc123") should equal ("abc")
+ Filter.filter("abc!@#$%^&*()123") should equal ("abc")
+ }
+ }
+ "character array with mixed characters" should returns {
+ "character array with non-letters removed" in {
+ Filter.filter("!@#$%^&*()abc".toCharArray) should equal ("abc".toCharArray)
+ Filter.filter("!@#$%^&*()abc123".toCharArray) should equal ("abc".toCharArray)
+ Filter.filter("abc!@#$%^&*()123".toCharArray) should equal ("abc".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiLetterOnlyFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiLetterOnlyFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala
new file mode 100755
index 0000000..7c24d45
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiNumberFilterSpec extends ScalaTest {
+ import AsciiNumberFilterSpec.Filter
+
+ "AsciiNumberFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with numbers" should returns {
+ "String with numbers removed" in {
+ Filter.filter(" Hello123World!") should equal (" HelloWorld!")
+ Filter.filter("123 HelloWorld!") should equal (" HelloWorld!")
+ Filter.filter(" HelloWorld!123") should equal (" HelloWorld!")
+ }
+ }
+ "character array with numbers" should returns {
+ "character array with numbers removed" in {
+ Filter.filter(" Hello123World!".toCharArray) should equal (" HelloWorld!".toCharArray)
+ Filter.filter("123 HelloWorld!".toCharArray) should equal (" HelloWorld!".toCharArray)
+ Filter.filter(" HelloWorld!123".toCharArray) should equal (" HelloWorld!".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiNumberFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiNumberFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala
new file mode 100755
index 0000000..db49d25
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiNumberOnlyFilterSpec extends ScalaTest {
+ import AsciiNumberOnlyFilterSpec.Filter
+
+ "AsciiNumberOnlyFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed characters" should returns {
+ "String with non-numbers removed" in {
+ Filter.filter("!@#$%^&*()abc123") should equal ("123")
+ Filter.filter("123!@#$%^&*()abc") should equal ("123")
+ Filter.filter("!@#$%^123&*()abc") should equal ("123")
+ }
+ }
+ "character array with mixed characters" should returns {
+ "character array with non-numbers removed" in {
+ Filter.filter("!@#$%^&*()abc123".toCharArray) should equal ("123".toCharArray)
+ Filter.filter("123!@#$%^&*()abc".toCharArray) should equal ("123".toCharArray)
+ Filter.filter("!@#$%^123&*()abc".toCharArray) should equal ("123".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiNumberOnlyFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiNumberOnlyFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala
new file mode 100755
index 0000000..759db3d
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala
@@ -0,0 +1,37 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiSpaceFilterSpec extends ScalaTest {
+ import AsciiSpaceFilterSpec.Filter
+
+ "AsciiSpaceFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with spaces" should returns {
+ "String with spaces removed" in {
+ Filter.filter("HelloWorld") should equal ("HelloWorld")
+ Filter.filter(" HelloWorld ") should equal ("HelloWorld")
+ Filter.filter("Hello World") should equal ("HelloWorld")
+ Filter.filter("H e l l o W o r l d") should equal ("HelloWorld")
+ Filter.filter("H e l l o W o r l d") should equal ("HelloWorld")
+ }
+ }
+ "character array with spaces" should returns {
+ "character array with spaces removed" in {
+ Filter.filter("HelloWorld".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter(" HelloWorld ".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("Hello World".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("H e l l o W o r l d".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("H e l l o W o r l d".toCharArray) should equal ("HelloWorld".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiSpaceFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiSpaceFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala
new file mode 100755
index 0000000..99be533
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala
@@ -0,0 +1,31 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiSymbolFilterSpec extends ScalaTest {
+ import AsciiSymbolFilterSpec.Filter
+
+ "AsciiSymbolFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with symbols" should returns {
+ "String with symbols removed" in {
+ Filter.filter("[HelloWorld]") should equal ("HelloWorld")
+ Filter.filter("Hello!World") should equal ("HelloWorld")
+ }
+ }
+ "character array with symbols" should returns {
+ "character array with symbols removed" in {
+ Filter.filter("[HelloWorld]".toCharArray) should equal ("HelloWorld".toCharArray)
+ Filter.filter("Hello!World".toCharArray) should equal ("HelloWorld".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiSymbolFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiSymbolFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala
new file mode 100755
index 0000000..c6f1899
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala
@@ -0,0 +1,33 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class AsciiSymbolOnlyFilterSpec extends ScalaTest {
+ import AsciiSymbolOnlyFilterSpec.Filter
+
+ "AsciiSymbolOnlyFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed characters" should returns {
+ "String with non-symbols removed" in {
+ Filter.filter("!@#$%^&*()abc123") should equal ("!@#$%^&*()")
+ Filter.filter("abc123!@#$%^&*()") should equal ("!@#$%^&*()")
+ Filter.filter("!@#$%abc123^&*()") should equal ("!@#$%^&*()")
+ }
+ }
+ "character array with mixed characters" should returns {
+ "character array with non-symbols removed" in {
+ Filter.filter("!@#$%^&*()abc123".toCharArray) should equal ("!@#$%^&*()".toCharArray)
+ Filter.filter("abc123!@#$%^&*()".toCharArray) should equal ("!@#$%^&*()".toCharArray)
+ Filter.filter("!@#$%abc123^&*()".toCharArray) should equal ("!@#$%^&*()".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object AsciiSymbolOnlyFilterSpec {
+ private final val Filter = new StringFilterDelegate with AsciiSymbolOnlyFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala
new file mode 100755
index 0000000..a04a0ae
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala
@@ -0,0 +1,41 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class IgnoreAsciiLetterCaseFilterSpec extends ScalaTest {
+ import IgnoreAsciiLetterCaseFilterSpec.Filter
+
+ "IgnoreAsciiLetterCaseFilter" should provide {
+ "overloaded filter method" when passed {
+ "String with mixed case" should returns {
+ "String with the same case" in {
+ Filter.filter("HelloWorld") should (equal ("helloworld") or equal ("HELLOWORLD"))
+ Filter.filter("Hello World") should (equal ("hello world") or equal ("HELLO WORLD"))
+ Filter.filter("H e l l o W o r l d") should
+ (equal ("h e l l o w o r l d") or equal ("H E L L O W O R L D"))
+ Filter.filter("H e l l o W o r l d") should
+ (equal ("h e l l o w o r l d") or equal ("H E L L O W O R L D"))
+ }
+ }
+ "character array with mixed case" should returns {
+ "character array with the same case" in {
+ Filter.filter("HelloWorld".toCharArray) should
+ (equal ("helloworld".toCharArray) or equal ("HELLOWORLD".toCharArray))
+ Filter.filter("Hello World".toCharArray) should
+ (equal ("hello world".toCharArray) or equal ("HELLO WORLD".toCharArray))
+ Filter.filter("H e l l o W o r l d".toCharArray) should
+ (equal ("h e l l o w o r l d".toCharArray) or equal ("H E L L O W O R L D".toCharArray))
+ Filter.filter("H e l l o W o r l d".toCharArray) should
+ (equal ("h e l l o w o r l d".toCharArray) or equal ("H E L L O W O R L D".toCharArray))
+ }
+ }
+ }
+ }
+}
+
+object IgnoreAsciiLetterCaseFilterSpec {
+ private final val Filter = new StringFilterDelegate with IgnoreAsciiLetterCaseFilter
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala
new file mode 100755
index 0000000..132156b
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala
@@ -0,0 +1,31 @@
+package com.rockymadden.stringmetric.filter
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class StringFilterDelegateSpec extends ScalaTest {
+ import StringFilterDelegateSpec.Filter
+
+ "StringFilter" should provide {
+ "overloaded filter method" when passed {
+ "String" should returns {
+ "the same String" in {
+ Filter.filter("Hello World") should equal ("Hello World")
+ Filter.filter(" Hello! World]") should equal (" Hello! World]")
+ }
+ }
+ "character array" should returns {
+ "the same character array" in {
+ Filter.filter("Hello World".toCharArray) should equal ("Hello World".toCharArray)
+ Filter.filter(" Hello! World]".toCharArray) should equal (" Hello! World]".toCharArray)
+ }
+ }
+ }
+ }
+}
+
+object StringFilterDelegateSpec {
+ private final val Filter = new StringFilterDelegate
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala
new file mode 100755
index 0000000..1f904d5
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala
@@ -0,0 +1,226 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class MetaphoneAlgorithmSpec extends ScalaTest {
+ import MetaphoneAlgorithmSpec.Algorithm
+
+ "MetaphoneAlgorithm" should provide {
+ "compute method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Algorithm.compute("").isDefined should be (false)
+ }
+ }
+ "non-phonetic argument" should returns {
+ "None" in {
+ Algorithm.compute("123").isDefined should be (false)
+ }
+ }
+ "phonetic argument" should returns {
+ "Some" in {
+ // z
+ Algorithm.compute("z").get should equal ("s")
+ Algorithm.compute("zz").get should equal ("s")
+
+ // y
+ Algorithm.compute("y").isDefined should be (false)
+ Algorithm.compute("zy").get should equal ("s")
+ Algorithm.compute("zyz").get should equal ("ss")
+ Algorithm.compute("zya").get should equal ("sy")
+
+ // x
+ Algorithm.compute("x").get should equal ("s")
+ Algorithm.compute("zx").get should equal ("sks")
+ Algorithm.compute("zxz").get should equal ("skss")
+
+ // w
+ Algorithm.compute("w").isDefined should be (false)
+ Algorithm.compute("zw").get should equal ("s")
+ Algorithm.compute("zwz").get should equal ("ss")
+ Algorithm.compute("zwa").get should equal ("sw")
+
+ // v
+ Algorithm.compute("v").get should equal ("f")
+ Algorithm.compute("zv").get should equal ("sf")
+ Algorithm.compute("zvz").get should equal ("sfs")
+
+ // u
+ Algorithm.compute("u").get should equal ("u")
+ Algorithm.compute("zu").get should equal ("s")
+
+ // t
+ Algorithm.compute("t").get should equal ("t")
+ Algorithm.compute("ztiaz").get should equal ("sxs")
+ Algorithm.compute("ztioz").get should equal ("sxs")
+ Algorithm.compute("zthz").get should equal ("s0s")
+ Algorithm.compute("ztchz").get should equal ("sxs")
+ Algorithm.compute("ztz").get should equal ("sts")
+
+ // s
+ Algorithm.compute("s").get should equal ("s")
+ Algorithm.compute("zshz").get should equal ("sxs")
+ Algorithm.compute("zsioz").get should equal ("sxs")
+ Algorithm.compute("zsiaz").get should equal ("sxs")
+ Algorithm.compute("zs").get should equal ("ss")
+ Algorithm.compute("zsz").get should equal ("sss")
+
+ // r
+ Algorithm.compute("r").get should equal ("r")
+ Algorithm.compute("zr").get should equal ("sr")
+ Algorithm.compute("zrz").get should equal ("srs")
+
+ // q
+ Algorithm.compute("q").get should equal ("k")
+ Algorithm.compute("zq").get should equal ("sk")
+ Algorithm.compute("zqz").get should equal ("sks")
+
+ // p
+ Algorithm.compute("p").get should equal ("p")
+ Algorithm.compute("zp").get should equal ("sp")
+ Algorithm.compute("zph").get should equal ("sf")
+ Algorithm.compute("zpz").get should equal ("sps")
+
+ // o
+ Algorithm.compute("o").get should equal ("o")
+ Algorithm.compute("zo").get should equal ("s")
+
+ // n
+ Algorithm.compute("n").get should equal ("n")
+ Algorithm.compute("zn").get should equal ("sn")
+ Algorithm.compute("znz").get should equal ("sns")
+
+ // m
+ Algorithm.compute("m").get should equal ("m")
+ Algorithm.compute("zm").get should equal ("sm")
+ Algorithm.compute("zmz").get should equal ("sms")
+
+ // l
+ Algorithm.compute("l").get should equal ("l")
+ Algorithm.compute("zl").get should equal ("sl")
+ Algorithm.compute("zlz").get should equal ("sls")
+
+ // k
+ Algorithm.compute("k").get should equal ("k")
+ Algorithm.compute("zk").get should equal ("sk")
+ Algorithm.compute("zck").get should equal ("sk")
+
+ // j
+ Algorithm.compute("j").get should equal ("j")
+ Algorithm.compute("zj").get should equal ("sj")
+ Algorithm.compute("zjz").get should equal ("sjs")
+
+ // i
+ Algorithm.compute("i").get should equal ("i")
+ Algorithm.compute("zi").get should equal ("s")
+
+ // h
+ Algorithm.compute("h").get should equal ("h") // php wrongly says nothing
+ Algorithm.compute("zh").get should equal ("sh") // php wrongly says s
+ Algorithm.compute("zah").get should equal ("s")
+ Algorithm.compute("zchh").get should equal ("sx")
+ Algorithm.compute("ha").get should equal ("h")
+
+ // g
+ Algorithm.compute("g").get should equal ("k")
+ Algorithm.compute("zg").get should equal ("sk")
+ Algorithm.compute("zgh").get should equal ("skh") // php wrongly says sf
+ Algorithm.compute("zghz").get should equal ("shs") // php wrongly says sfs
+ Algorithm.compute("zgha").get should equal ("sh") // php wrongly says sf others wrongly say skh
+ Algorithm.compute("zgn").get should equal ("sn")
+ Algorithm.compute("zgns").get should equal ("skns")
+ Algorithm.compute("zgned").get should equal ("snt") // others wrongly says sknt
+ Algorithm.compute("zgneds").get should equal ("sknts") // php wrongly says snts
+ Algorithm.compute("zgi").get should equal ("sj")
+ Algorithm.compute("zgiz").get should equal ("sjs")
+ Algorithm.compute("zge").get should equal ("sj")
+ Algorithm.compute("zgez").get should equal ("sjs")
+ Algorithm.compute("zgy").get should equal ("sj")
+ Algorithm.compute("zgyz").get should equal ("sjs")
+ Algorithm.compute("zgz").get should equal ("sks")
+
+ // f
+ Algorithm.compute("f").get should equal ("f")
+ Algorithm.compute("zf").get should equal ("sf")
+ Algorithm.compute("zfz").get should equal ("sfs")
+
+ // e
+ Algorithm.compute("e").get should equal ("e")
+ Algorithm.compute("ze").get should equal ("s")
+
+ // d
+ Algorithm.compute("d").get should equal ("t")
+ Algorithm.compute("fudge").get should equal ("fjj") // php wrongly says fj
+ Algorithm.compute("dodgy").get should equal ("tjj") // php wrongly says tj others wrongly say tjjy
+ Algorithm.compute("dodgi").get should equal ("tjj") // php wrongly says tj
+ Algorithm.compute("zd").get should equal ("st")
+ Algorithm.compute("zdz").get should equal ("sts")
+
+ // c
+ Algorithm.compute("c").get should equal ("k")
+ Algorithm.compute("zcia").get should equal ("sx")
+ Algorithm.compute("zciaz").get should equal ("sxs")
+ Algorithm.compute("zch").get should equal ("sx")
+ Algorithm.compute("zchz").get should equal ("sxs")
+ Algorithm.compute("zci").get should equal ("ss")
+ Algorithm.compute("zciz").get should equal ("sss")
+ Algorithm.compute("zce").get should equal ("ss")
+ Algorithm.compute("zcez").get should equal ("sss")
+ Algorithm.compute("zcy").get should equal ("ss")
+ Algorithm.compute("zcyz").get should equal ("sss")
+ Algorithm.compute("zsci").get should equal ("ss")
+ Algorithm.compute("zsciz").get should equal ("sss")
+ Algorithm.compute("zsce").get should equal ("ss")
+ Algorithm.compute("zscez").get should equal ("sss")
+ Algorithm.compute("zscy").get should equal ("ss")
+ Algorithm.compute("zscyz").get should equal ("sss")
+ Algorithm.compute("zsch").get should equal ("sskh") // php wrongly says ssx
+ Algorithm.compute("zc").get should equal ("sk")
+ Algorithm.compute("zcz").get should equal ("sks")
+
+ // b
+ Algorithm.compute("b").get should equal ("b")
+ Algorithm.compute("zb").get should equal ("sb")
+ Algorithm.compute("zbz").get should equal ("sbs")
+ Algorithm.compute("zmb").get should equal ("sm")
+
+ // a
+ Algorithm.compute("a").get should equal ("a")
+ Algorithm.compute("za").get should equal ("s")
+
+ // Miscellaneous.
+ Algorithm.compute("dumb").get should equal ("tm")
+ Algorithm.compute("smith").get should equal ("sm0")
+ Algorithm.compute("school").get should equal ("skhl") // php wrongly says sxl
+ Algorithm.compute("merci").get should equal ("mrs")
+ Algorithm.compute("cool").get should equal ("kl")
+ Algorithm.compute("aebersold").get should equal ("ebrslt")
+ Algorithm.compute("gnagy").get should equal ("nj")
+ Algorithm.compute("knuth").get should equal ("n0")
+ Algorithm.compute("pniewski").get should equal ("nsk")
+ Algorithm.compute("wright").get should equal ("rht") // php wrongly says rft
+ Algorithm.compute("phone").get should equal ("fn")
+ Algorithm.compute("aggregate").get should equal ("akrkt")
+ Algorithm.compute("accuracy").get should equal ("akkrs")
+ Algorithm.compute("encyclopedia").get should equal ("ensklpt")
+ Algorithm.compute("honorificabilitudinitatibus").get should equal ("hnrfkblttnttbs")
+ Algorithm.compute("antidisestablishmentarianism").get should equal ("anttsstblxmntrnsm")
+ }
+ }
+ }
+ }
+ "MetaphoneAlgorithm companion object" should provide {
+ "pass-through compute method" should returns {
+ "same value as class" in {
+ MetaphoneAlgorithm.compute("dumb").get should equal ("tm")
+ }
+ }
+ }
+}
+
+object MetaphoneAlgorithmSpec {
+ final private val Algorithm = MetaphoneAlgorithm()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala
new file mode 100755
index 0000000..9a029d8
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala
@@ -0,0 +1,54 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class MetaphoneMetricSpec extends ScalaTest {
+ import MetaphoneMetricSpec.Metric
+
+ "MetaphoneMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "non-phonetic arguments" should returns {
+ "None" in {
+ Metric.compare("123", "123").isDefined should be (false)
+ Metric.compare("123", "").isDefined should be (false)
+ Metric.compare("", "123").isDefined should be (false)
+ }
+ }
+ "phonetically similar arguments" should returns {
+ "Boolean indicating true" in {
+ Metric.compare("dumb", "dum").get should be (true)
+ Metric.compare("smith", "smeth").get should be (true)
+ Metric.compare("merci", "mercy").get should be (true)
+ }
+ }
+ "phonetically dissimilar arguments" should returns {
+ "Boolean indicating false" in {
+ Metric.compare("dumb", "gum").get should be (false)
+ Metric.compare("smith", "kiss").get should be (false)
+ Metric.compare("merci", "burpy").get should be (false)
+ }
+ }
+ }
+ }
+ "MetaphoneMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ MetaphoneMetric.compare("dumb", "gum").get should be (false)
+ }
+ }
+ }
+}
+
+object MetaphoneMetricSpec {
+ final private val Metric = MetaphoneMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala
new file mode 100755
index 0000000..6a0f113
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala
@@ -0,0 +1,204 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class NysiisAlgorithmSpec extends ScalaTest {
+ import NysiisAlgorithmSpec.Algorithm
+
+ "NysiisAlgorithm" should provide {
+ "compute method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Algorithm.compute("").isDefined should be (false)
+ }
+ }
+ "non-phonetic argument" should returns {
+ "None" in {
+ Algorithm.compute("123").isDefined should be (false)
+ }
+ }
+ "phonetic argument" should returns {
+ "Some" in {
+ // a
+ Algorithm.compute("a").get should equal ("a")
+ Algorithm.compute("aa").get should equal ("a")
+
+ // b
+ Algorithm.compute("b").get should equal ("b")
+ Algorithm.compute("bb").get should equal ("bb")
+
+ // c
+ Algorithm.compute("c").get should equal ("c")
+ Algorithm.compute("cc").get should equal ("cc")
+
+ // d
+ Algorithm.compute("d").get should equal ("d")
+ Algorithm.compute("dd").get should equal ("dd")
+
+ // e
+ Algorithm.compute("e").get should equal ("e")
+ Algorithm.compute("ee").get should equal ("y")
+
+ // f
+ Algorithm.compute("f").get should equal ("f")
+ Algorithm.compute("ff").get should equal ("ff")
+
+ // g
+ Algorithm.compute("g").get should equal ("g")
+ Algorithm.compute("gg").get should equal ("gg")
+
+ // h
+ Algorithm.compute("h").get should equal ("h")
+ Algorithm.compute("hh").get should equal ("hh")
+
+ // i
+ Algorithm.compute("i").get should equal ("i")
+ Algorithm.compute("ii").get should equal ("i")
+
+ // j
+ Algorithm.compute("j").get should equal ("j")
+ Algorithm.compute("jj").get should equal ("jj")
+
+ // k
+ Algorithm.compute("k").get should equal ("c")
+ Algorithm.compute("kk").get should equal ("cc")
+
+ // l
+ Algorithm.compute("l").get should equal ("l")
+ Algorithm.compute("ll").get should equal ("ll")
+
+ // m
+ Algorithm.compute("m").get should equal ("m")
+ Algorithm.compute("mm").get should equal ("mn")
+
+ // n
+ Algorithm.compute("n").get should equal ("n")
+ Algorithm.compute("nn").get should equal ("nn")
+
+ // o
+ Algorithm.compute("o").get should equal ("o")
+ Algorithm.compute("oo").get should equal ("o")
+
+ // p
+ Algorithm.compute("p").get should equal ("p")
+ Algorithm.compute("pp").get should equal ("pp")
+
+ // q
+ Algorithm.compute("q").get should equal ("q")
+ Algorithm.compute("qq").get should equal ("qg")
+
+ // r
+ Algorithm.compute("r").get should equal ("r")
+ Algorithm.compute("rr").get should equal ("rr")
+
+ // s
+ Algorithm.compute("s").get should equal ("s")
+ Algorithm.compute("ss").get should equal ("s")
+
+ // t
+ Algorithm.compute("t").get should equal ("t")
+ Algorithm.compute("tt").get should equal ("tt")
+
+ // u
+ Algorithm.compute("u").get should equal ("u")
+ Algorithm.compute("uu").get should equal ("u")
+
+ // v
+ Algorithm.compute("v").get should equal ("v")
+ Algorithm.compute("vv").get should equal ("vv")
+
+ // w
+ Algorithm.compute("w").get should equal ("w")
+ Algorithm.compute("ww").get should equal ("ww")
+
+ // x
+ Algorithm.compute("x").get should equal ("x")
+ Algorithm.compute("xx").get should equal ("xx")
+
+ // y
+ Algorithm.compute("y").get should equal ("y")
+ Algorithm.compute("yy").get should equal ("yy")
+
+ // z
+ Algorithm.compute("z").get should equal ("z")
+ Algorithm.compute("zz").get should equal ("z")
+
+ // Head cases.
+ Algorithm.compute("mac").get should equal ("mc")
+ Algorithm.compute("kn").get should equal ("nn")
+ Algorithm.compute("k").get should equal ("c")
+ Algorithm.compute("ph").get should equal ("ff")
+ Algorithm.compute("pf").get should equal ("ff")
+ Algorithm.compute("sch").get should equal ("s") // dropby wrongly says ss
+
+ // Last cases.
+ Algorithm.compute("ee").get should equal ("y")
+ Algorithm.compute("ie").get should equal ("y")
+ Algorithm.compute("dt").get should equal ("d")
+ Algorithm.compute("rt").get should equal ("d")
+ Algorithm.compute("rd").get should equal ("d")
+ Algorithm.compute("nt").get should equal ("d")
+ Algorithm.compute("nd").get should equal ("d")
+
+ // Core cases.
+ Algorithm.compute("eev").get should equal ("eaf")
+ Algorithm.compute("zev").get should equal ("zaf")
+ Algorithm.compute("kkn").get should equal ("cn")
+ Algorithm.compute("sschn").get should equal ("ssn")
+ Algorithm.compute("pph").get should equal ("pf")
+
+ // Miscellaneous.
+ Algorithm.compute("macdonald").get should equal ("mcdanald")
+ Algorithm.compute("phone").get should equal ("ffan")
+ Algorithm.compute("aggregate").get should equal ("agragat")
+ Algorithm.compute("accuracy").get should equal ("acaracy")
+ Algorithm.compute("encyclopedia").get should equal ("encyclapad")
+ Algorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab")
+ Algorithm.compute("antidisestablishmentarianism").get should equal ("antadasastablasnantaranasn")
+
+ // Dropby.
+ Algorithm.compute("macintosh").get should equal ("mcant")
+ Algorithm.compute("knuth").get should equal ("nnat")
+ Algorithm.compute("koehn").get should equal ("can") // dropby wrongly says c
+ Algorithm.compute("phillipson").get should equal ("ffalapsan")
+ Algorithm.compute("pfeister").get should equal ("ffastar")
+ Algorithm.compute("schoenhoeft").get should equal ("ssanaft")
+ Algorithm.compute("mckee").get should equal ("mcy")
+ Algorithm.compute("heitschmedt").get should equal ("hatsnad")
+ Algorithm.compute("bart").get should equal ("bad")
+ Algorithm.compute("hurd").get should equal ("had")
+ Algorithm.compute("hunt").get should equal ("had")
+ Algorithm.compute("westerlund").get should equal ("wastarlad")
+ Algorithm.compute("casstevens").get should equal ("castafan")
+ Algorithm.compute("vasquez").get should equal ("vasg")
+ Algorithm.compute("frazier").get should equal ("frasar")
+ Algorithm.compute("bowman").get should equal ("banan")
+ Algorithm.compute("mcknight").get should equal ("mcnagt")
+ Algorithm.compute("rickert").get should equal ("racad")
+ Algorithm.compute("deutsch").get should equal ("dat") // dropby wrongly says dats
+ Algorithm.compute("westphal").get should equal ("wastfal")
+ Algorithm.compute("shriver").get should equal ("shravar")
+ Algorithm.compute("kuhl").get should equal ("cal") // dropby wrongly says c
+ Algorithm.compute("rawson").get should equal ("rasan")
+ Algorithm.compute("jiles").get should equal ("jal")
+ Algorithm.compute("carraway").get should equal ("caray")
+ Algorithm.compute("yamada").get should equal ("yanad")
+ }
+ }
+ }
+ }
+ "NysiisAlgorithm companion object" should provide {
+ "pass-through compute method" should returns {
+ "same value as class" in {
+ NysiisAlgorithm.compute("macdonald").get should equal ("mcdanald")
+ }
+ }
+ }
+}
+
+object NysiisAlgorithmSpec {
+ final private val Algorithm = NysiisAlgorithm()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala
new file mode 100755
index 0000000..c6929a2
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala
@@ -0,0 +1,50 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class NysiisMetricSpec extends ScalaTest {
+ import NysiisMetricSpec.Metric
+
+ "NysiisMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "non-phonetic arguments" should returns {
+ "None" in {
+ Metric.compare("123", "123").isDefined should be (false)
+ Metric.compare("123", "").isDefined should be (false)
+ Metric.compare("", "123").isDefined should be (false)
+ }
+ }
+ "phonetically similar arguments" should returns {
+ "Boolean indicating true" in {
+ Metric.compare("ham", "hum").get should be (true)
+ }
+ }
+ "phonetically dissimilar arguments" should returns {
+ "Boolean indicating false" in {
+ Metric.compare("dumb", "gum").get should be (false)
+ }
+ }
+ }
+ }
+ "NysiisMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ NysiisMetric.compare("dumb", "gum").get should be (false)
+ }
+ }
+ }
+}
+
+object NysiisMetricSpec {
+ final private val Metric = NysiisMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala
new file mode 100755
index 0000000..1298d2d
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala
@@ -0,0 +1,221 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class RefinedNysiisAlgorithmSpec extends ScalaTest {
+ import RefinedNysiisAlgorithmSpec.Algorithm
+
+ "RefinedNysiisAlgorithm" should provide {
+ "compute method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Algorithm.compute("").isDefined should be (false)
+ }
+ }
+ "non-phonetic argument" should returns {
+ "None" in {
+ Algorithm.compute("123").isDefined should be (false)
+ }
+ }
+ "phonetic argument" should returns {
+ "Some" in {
+ // a
+ Algorithm.compute("a").get should equal ("a")
+ Algorithm.compute("aa").get should equal ("a")
+
+ // b
+ Algorithm.compute("b").get should equal ("b")
+ Algorithm.compute("bb").get should equal ("b")
+
+ // c
+ Algorithm.compute("c").get should equal ("c")
+ Algorithm.compute("cc").get should equal ("c")
+
+ // d
+ Algorithm.compute("d").get should equal ("d")
+ Algorithm.compute("dd").get should equal ("d")
+
+ // e
+ Algorithm.compute("e").get should equal ("e")
+ Algorithm.compute("ee").get should equal ("y")
+
+ // f
+ Algorithm.compute("f").get should equal ("f")
+ Algorithm.compute("ff").get should equal ("f")
+
+ // g
+ Algorithm.compute("g").get should equal ("g")
+ Algorithm.compute("gg").get should equal ("g")
+
+ // h
+ Algorithm.compute("h").get should equal ("h")
+ Algorithm.compute("hh").get should equal ("h")
+
+ // i
+ Algorithm.compute("i").get should equal ("i")
+ Algorithm.compute("ii").get should equal ("i")
+
+ // j
+ Algorithm.compute("j").get should equal ("j")
+ Algorithm.compute("jj").get should equal ("j")
+
+ // k
+ Algorithm.compute("k").get should equal ("c")
+ Algorithm.compute("kk").get should equal ("c")
+
+ // l
+ Algorithm.compute("l").get should equal ("l")
+ Algorithm.compute("ll").get should equal ("l")
+
+ // m
+ Algorithm.compute("m").get should equal ("m")
+ Algorithm.compute("mm").get should equal ("mn")
+
+ // n
+ Algorithm.compute("n").get should equal ("n")
+ Algorithm.compute("nn").get should equal ("n")
+
+ // o
+ Algorithm.compute("o").get should equal ("o")
+ Algorithm.compute("oo").get should equal ("o")
+
+ // p
+ Algorithm.compute("p").get should equal ("p")
+ Algorithm.compute("pp").get should equal ("p")
+
+ // q
+ Algorithm.compute("q").get should equal ("q")
+ Algorithm.compute("qq").get should equal ("qg")
+
+ // r
+ Algorithm.compute("r").get should equal ("r")
+ Algorithm.compute("rr").get should equal ("r")
+
+ // s
+ Algorithm.compute("s").get should equal ("s")
+ Algorithm.compute("ss").get should equal ("s")
+
+ // t
+ Algorithm.compute("t").get should equal ("t")
+ Algorithm.compute("tt").get should equal ("t")
+
+ // u
+ Algorithm.compute("u").get should equal ("u")
+ Algorithm.compute("uu").get should equal ("u")
+
+ // v
+ Algorithm.compute("v").get should equal ("v")
+ Algorithm.compute("vv").get should equal ("v")
+
+ // w
+ Algorithm.compute("w").get should equal ("w")
+ Algorithm.compute("ww").get should equal ("w")
+
+ // x
+ Algorithm.compute("x").get should equal ("x")
+ Algorithm.compute("xx").get should equal ("x")
+
+ // y
+ Algorithm.compute("y").get should equal ("y")
+ Algorithm.compute("yy").get should equal ("y")
+ Algorithm.compute("ybyb").get should equal ("ybab")
+
+ // z
+ Algorithm.compute("z").get should equal ("z")
+ Algorithm.compute("zz").get should equal ("z")
+
+ // Head cases.
+ Algorithm.compute("mac").get should equal ("mc")
+ Algorithm.compute("pf").get should equal ("f")
+
+ // Last cases.
+ Algorithm.compute("ix").get should equal ("ic")
+ Algorithm.compute("ex").get should equal ("ec")
+ Algorithm.compute("ye").get should equal ("y")
+ Algorithm.compute("ee").get should equal ("y")
+ Algorithm.compute("ie").get should equal ("y")
+ Algorithm.compute("dt").get should equal ("d")
+ Algorithm.compute("rt").get should equal ("d")
+ Algorithm.compute("rd").get should equal ("d")
+ Algorithm.compute("nt").get should equal ("d")
+ Algorithm.compute("nd").get should equal ("d")
+
+ // Core cases.
+ Algorithm.compute("bevb").get should equal ("bafb")
+ Algorithm.compute("bghtb").get should equal ("bgtb")
+ Algorithm.compute("bdgb").get should equal ("bgb")
+ Algorithm.compute("bphb").get should equal ("bfb")
+ Algorithm.compute("bknb").get should equal ("bnb")
+ Algorithm.compute("bshb").get should equal ("bsb")
+ Algorithm.compute("bschb").get should equal ("bsb")
+ Algorithm.compute("bywb").get should equal ("bab")
+ Algorithm.compute("byw").get should equal ("by")
+ Algorithm.compute("ywb").get should equal ("yb")
+ Algorithm.compute("bwrb").get should equal ("brb")
+
+ // Transcode cases.
+ Algorithm.compute("bay").get should equal ("by")
+
+ // Miscellaneous.
+ Algorithm.compute("macdonald").get should equal ("mcdanald")
+ Algorithm.compute("phone").get should equal ("fan")
+ Algorithm.compute("aggregate").get should equal ("agragat")
+ Algorithm.compute("accuracy").get should equal ("acaracy")
+ Algorithm.compute("encyclopedia").get should equal ("encaclapad")
+ Algorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab")
+ Algorithm.compute("antidisestablishmentarianism").get should equal ("antadasastablasnantaranasn")
+
+ // Dropby.
+ Algorithm.compute("edwards").get should equal ("edwad")
+ Algorithm.compute("parez").get should equal ("par")
+ Algorithm.compute("macintosh").get should equal ("mcantas")
+ Algorithm.compute("phillipson").get should equal ("falapsan")
+ Algorithm.compute("haddix").get should equal ("hadac")
+ Algorithm.compute("essex").get should equal ("esac")
+ Algorithm.compute("moye").get should equal ("my")
+ Algorithm.compute("mckee").get should equal ("mcy")
+ Algorithm.compute("mackie").get should equal ("mcy")
+ Algorithm.compute("heitschmidt").get should equal ("hatsnad")
+ Algorithm.compute("bart").get should equal ("bad")
+ Algorithm.compute("hurd").get should equal ("had")
+ Algorithm.compute("hunt").get should equal ("had")
+ Algorithm.compute("westerlund").get should equal ("wastarlad")
+ Algorithm.compute("evers").get should equal ("evar")
+ Algorithm.compute("devito").get should equal ("dafat")
+ Algorithm.compute("rawson").get should equal ("rasan")
+ Algorithm.compute("shoulders").get should equal ("saldar")
+ Algorithm.compute("leighton").get should equal ("lagtan")
+ Algorithm.compute("wooldridge").get should equal ("waldrag")
+ Algorithm.compute("oliphant").get should equal ("olafad")
+ Algorithm.compute("hatchett").get should equal ("hatcat")
+ Algorithm.compute("mcknight").get should equal ("mcnagt")
+ Algorithm.compute("rickert").get should equal ("racad")
+ Algorithm.compute("bowman").get should equal ("banan")
+ Algorithm.compute("vasquez").get should equal ("vasg")
+ Algorithm.compute("bashaw").get should equal ("bas")
+ Algorithm.compute("schoenhoeft").get should equal ("sanaft") // dropby wrongly says scanaft
+ Algorithm.compute("heywood").get should equal ("had")
+ Algorithm.compute("hayman").get should equal ("hanan")
+ Algorithm.compute("seawright").get should equal ("saragt")
+ Algorithm.compute("kratzer").get should equal ("cratsar")
+ Algorithm.compute("canaday").get should equal ("canady")
+ Algorithm.compute("crepeau").get should equal ("crap")
+ }
+ }
+ }
+ }
+ "RefinedNysiisAlgorithm companion object" should provide {
+ "pass-through compute method" should returns {
+ "same value as class" in {
+ RefinedNysiisAlgorithm.compute("macdonald").get should equal ("mcdanald")
+ }
+ }
+ }
+}
+
+object RefinedNysiisAlgorithmSpec {
+ final private val Algorithm = RefinedNysiisAlgorithm()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala
new file mode 100755
index 0000000..ca9d2ec
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala
@@ -0,0 +1,50 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class RefinedNysiisMetricSpec extends ScalaTest {
+ import RefinedNysiisMetricSpec.Metric
+
+ "RefinedNysiisMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "non-phonetic arguments" should returns {
+ "None" in {
+ Metric.compare("123", "123").isDefined should be (false)
+ Metric.compare("123", "").isDefined should be (false)
+ Metric.compare("", "123").isDefined should be (false)
+ }
+ }
+ "phonetically similar arguments" should returns {
+ "Boolean indicating true" in {
+ Metric.compare("ham", "hum").get should be (true)
+ }
+ }
+ "phonetically dissimilar arguments" should returns {
+ "Boolean indicating false" in {
+ Metric.compare("dumb", "gum").get should be (false)
+ }
+ }
+ }
+ }
+ "RefinedNysiisMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ RefinedNysiisMetric.compare("dumb", "gum").get should be (false)
+ }
+ }
+ }
+}
+
+object RefinedNysiisMetricSpec {
+ final private val Metric = RefinedNysiisMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala
new file mode 100755
index 0000000..254bf06
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala
@@ -0,0 +1,175 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class RefinedSoundexAlgorithmSpec extends ScalaTest {
+ import RefinedSoundexAlgorithmSpec.Algorithm
+
+ "RefinedSoundexAlgorithm" should provide {
+ "compute method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Algorithm.compute("").isDefined should be (false)
+ }
+ }
+ "non-phonetic argument" should returns {
+ "None" in {
+ Algorithm.compute("123").isDefined should be (false)
+ }
+ }
+ "phonetic argument" should returns {
+ "Some" in {
+ // a
+ Algorithm.compute("a").get should equal ("a0")
+ Algorithm.compute("aa").get should equal ("a0")
+
+ // b
+ Algorithm.compute("b").get should equal ("b1")
+ Algorithm.compute("bb").get should equal ("b1")
+
+ // c
+ Algorithm.compute("c").get should equal ("c3")
+ Algorithm.compute("cc").get should equal ("c3")
+
+ // d
+ Algorithm.compute("d").get should equal ("d6")
+ Algorithm.compute("dd").get should equal ("d6")
+
+ // e
+ Algorithm.compute("e").get should equal ("e0")
+ Algorithm.compute("ee").get should equal ("e0")
+
+ // f
+ Algorithm.compute("f").get should equal ("f2")
+ Algorithm.compute("ff").get should equal ("f2")
+
+ // g
+ Algorithm.compute("g").get should equal ("g4")
+ Algorithm.compute("gg").get should equal ("g4")
+
+ // h
+ Algorithm.compute("h").get should equal ("h0")
+ Algorithm.compute("hh").get should equal ("h0")
+
+ // i
+ Algorithm.compute("i").get should equal ("i0")
+ Algorithm.compute("ii").get should equal ("i0")
+
+ // j
+ Algorithm.compute("j").get should equal ("j4")
+ Algorithm.compute("jj").get should equal ("j4")
+
+ // k
+ Algorithm.compute("k").get should equal ("k3")
+ Algorithm.compute("kk").get should equal ("k3")
+
+ // l
+ Algorithm.compute("l").get should equal ("l7")
+ Algorithm.compute("ll").get should equal ("l7")
+
+ // m
+ Algorithm.compute("m").get should equal ("m8")
+ Algorithm.compute("mm").get should equal ("m8")
+
+ // n
+ Algorithm.compute("n").get should equal ("n8")
+ Algorithm.compute("nn").get should equal ("n8")
+
+ // o
+ Algorithm.compute("o").get should equal ("o0")
+ Algorithm.compute("oo").get should equal ("o0")
+
+ // p
+ Algorithm.compute("p").get should equal ("p1")
+ Algorithm.compute("pp").get should equal ("p1")
+
+ // q
+ Algorithm.compute("q").get should equal ("q5")
+ Algorithm.compute("qq").get should equal ("q5")
+
+ // r
+ Algorithm.compute("r").get should equal ("r9")
+ Algorithm.compute("rr").get should equal ("r9")
+
+ // s
+ Algorithm.compute("s").get should equal ("s3")
+ Algorithm.compute("ss").get should equal ("s3")
+
+ // t
+ Algorithm.compute("t").get should equal ("t6")
+ Algorithm.compute("tt").get should equal ("t6")
+
+ // u
+ Algorithm.compute("u").get should equal ("u0")
+ Algorithm.compute("uu").get should equal ("u0")
+
+ // v
+ Algorithm.compute("v").get should equal ("v2")
+ Algorithm.compute("vv").get should equal ("v2")
+
+ // w
+ Algorithm.compute("w").get should equal ("w0")
+ Algorithm.compute("ww").get should equal ("w0")
+
+ // x
+ Algorithm.compute("x").get should equal ("x5")
+ Algorithm.compute("xx").get should equal ("x5")
+
+ // y
+ Algorithm.compute("y").get should equal ("y0")
+ Algorithm.compute("yy").get should equal ("y0")
+
+ // z
+ Algorithm.compute("z").get should equal ("z5")
+ Algorithm.compute("zz").get should equal ("z5")
+
+ // Starting with letter then numbers.
+ Algorithm.compute("x123456").get should equal ("x5")
+ Algorithm.compute("a123456").get should equal ("a0")
+ Algorithm.compute("f123456").get should equal ("f2")
+
+ // Miscellaneous.
+ Algorithm.compute("braz").get should equal ("b1905")
+ Algorithm.compute("broz").get should equal ("b1905")
+ Algorithm.compute("caren").get should equal ("c30908")
+ Algorithm.compute("carren").get should equal ("c30908")
+ Algorithm.compute("coram").get should equal ("c30908")
+ Algorithm.compute("corran").get should equal ("c30908")
+ Algorithm.compute("curreen").get should equal ("c30908")
+ Algorithm.compute("curwen").get should equal ("c30908")
+ Algorithm.compute("hairs").get should equal ("h093")
+ Algorithm.compute("hark").get should equal ("h093")
+ Algorithm.compute("hars").get should equal ("h093")
+ Algorithm.compute("hayers").get should equal ("h093")
+ Algorithm.compute("heers").get should equal ("h093")
+ Algorithm.compute("hiers").get should equal ("h093")
+ Algorithm.compute("lambard").get should equal ("l7081096")
+ Algorithm.compute("lambart").get should equal ("l7081096")
+ Algorithm.compute("lambert").get should equal ("l7081096")
+ Algorithm.compute("lambird").get should equal ("l7081096")
+ Algorithm.compute("lampaert").get should equal ("l7081096")
+ Algorithm.compute("lampart").get should equal ("l7081096")
+ Algorithm.compute("lamport").get should equal ("l7081096")
+ Algorithm.compute("limbert").get should equal ("l7081096")
+ Algorithm.compute("lombard").get should equal ("l7081096")
+ Algorithm.compute("nolton").get should equal ("n807608")
+ Algorithm.compute("noulton").get should equal ("n807608")
+ }
+ }
+ }
+ }
+ "RefinedSoundexAlgorithm companion object" should provide {
+ "pass-through compute method" should returns {
+ "same value as class" in {
+ RefinedSoundexAlgorithm.compute("braz").get should equal ("b1905")
+ }
+ }
+ }
+}
+
+object RefinedSoundexAlgorithmSpec {
+ final private val Algorithm = RefinedSoundexAlgorithm()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala
new file mode 100755
index 0000000..cb6a222
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala
@@ -0,0 +1,50 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class RefinedSoundexMetricSpec extends ScalaTest {
+ import RefinedSoundexMetricSpec.Metric
+
+ "RefinedSoundexMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "non-phonetic arguments" should returns {
+ "None" in {
+ Metric.compare("123", "123").isDefined should be (false)
+ Metric.compare("123", "").isDefined should be (false)
+ Metric.compare("", "123").isDefined should be (false)
+ }
+ }
+ "phonetically similar arguments" should returns {
+ "Boolean indicating true" in {
+ Metric.compare("robert", "rupert").get should be (true)
+ }
+ }
+ "phonetically dissimilar arguments" should returns {
+ "Boolean indicating false" in {
+ Metric.compare("robert", "rubin").get should be (false)
+ }
+ }
+ }
+ }
+ "RefinedSoundexMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ RefinedSoundexMetric.compare("robert", "rubin").get should be (false)
+ }
+ }
+ }
+}
+
+object RefinedSoundexMetricSpec {
+ final private val Metric = RefinedSoundexMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala
new file mode 100755
index 0000000..5b7deaa
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala
@@ -0,0 +1,174 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class SoundexAlgorithmSpec extends ScalaTest {
+ import SoundexAlgorithmSpec.Algorithm
+
+ "SoundexAlgorithm" should provide {
+ "compute method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Algorithm.compute("").isDefined should be (false)
+ }
+ }
+ "non-phonetic argument" should returns {
+ "None" in {
+ Algorithm.compute("123").isDefined should be (false)
+ }
+ }
+ "phonetic argument" should returns {
+ "Some" in {
+ // a
+ Algorithm.compute("a").get should equal ("a000")
+ Algorithm.compute("aa").get should equal ("a000")
+
+ // b
+ Algorithm.compute("b").get should equal ("b000")
+ Algorithm.compute("bb").get should equal ("b000")
+
+ // c
+ Algorithm.compute("c").get should equal ("c000")
+ Algorithm.compute("cc").get should equal ("c000")
+
+ // d
+ Algorithm.compute("d").get should equal ("d000")
+ Algorithm.compute("dd").get should equal ("d000")
+
+ // e
+ Algorithm.compute("e").get should equal ("e000")
+ Algorithm.compute("ee").get should equal ("e000")
+
+ // f
+ Algorithm.compute("f").get should equal ("f000")
+ Algorithm.compute("ff").get should equal ("f000")
+
+ // g
+ Algorithm.compute("g").get should equal ("g000")
+ Algorithm.compute("gg").get should equal ("g000")
+
+ // h
+ Algorithm.compute("h").get should equal ("h000")
+ Algorithm.compute("hh").get should equal ("h000")
+
+ // i
+ Algorithm.compute("i").get should equal ("i000")
+ Algorithm.compute("ii").get should equal ("i000")
+
+ // j
+ Algorithm.compute("j").get should equal ("j000")
+ Algorithm.compute("jj").get should equal ("j000")
+
+ // k
+ Algorithm.compute("k").get should equal ("k000")
+ Algorithm.compute("kk").get should equal ("k000")
+
+ // l
+ Algorithm.compute("l").get should equal ("l000")
+ Algorithm.compute("ll").get should equal ("l000")
+
+ // m
+ Algorithm.compute("m").get should equal ("m000")
+ Algorithm.compute("mm").get should equal ("m000")
+
+ // n
+ Algorithm.compute("n").get should equal ("n000")
+ Algorithm.compute("nn").get should equal ("n000")
+
+ // o
+ Algorithm.compute("o").get should equal ("o000")
+ Algorithm.compute("oo").get should equal ("o000")
+
+ // p
+ Algorithm.compute("p").get should equal ("p000")
+ Algorithm.compute("pp").get should equal ("p000")
+
+ // q
+ Algorithm.compute("q").get should equal ("q000")
+ Algorithm.compute("qq").get should equal ("q000")
+
+ // r
+ Algorithm.compute("r").get should equal ("r000")
+ Algorithm.compute("rr").get should equal ("r000")
+
+ // s
+ Algorithm.compute("s").get should equal ("s000")
+ Algorithm.compute("ss").get should equal ("s000")
+
+ // t
+ Algorithm.compute("t").get should equal ("t000")
+ Algorithm.compute("tt").get should equal ("t000")
+
+ // u
+ Algorithm.compute("u").get should equal ("u000")
+ Algorithm.compute("uu").get should equal ("u000")
+
+ // v
+ Algorithm.compute("v").get should equal ("v000")
+ Algorithm.compute("vv").get should equal ("v000")
+
+ // w
+ Algorithm.compute("w").get should equal ("w000")
+ Algorithm.compute("ww").get should equal ("w000")
+
+ // x
+ Algorithm.compute("x").get should equal ("x000")
+ Algorithm.compute("xx").get should equal ("x000")
+
+ // y
+ Algorithm.compute("y").get should equal ("y000")
+ Algorithm.compute("yy").get should equal ("y000")
+
+ // z
+ Algorithm.compute("z").get should equal ("z000")
+ Algorithm.compute("zz").get should equal ("z000")
+
+ // Starting with letter then numbers.
+ Algorithm.compute("x123456").get should equal ("x000")
+ Algorithm.compute("a123456").get should equal ("a000")
+ Algorithm.compute("f123456").get should equal ("f000")
+
+ // Miscellaneous.
+ Algorithm.compute("abc").get should equal ("a120")
+ Algorithm.compute("xyz").get should equal ("x200")
+ Algorithm.compute("robert").get should equal ("r163")
+ Algorithm.compute("rupert").get should equal ("r163")
+ Algorithm.compute("rubin").get should equal ("r150")
+ Algorithm.compute("ashcraft").get should equal ("a261")
+ Algorithm.compute("tymczak").get should equal ("t522")
+ Algorithm.compute("pfister").get should equal ("p236")
+ Algorithm.compute("euler").get should equal ("e460")
+ Algorithm.compute("gauss").get should equal ("g200")
+ Algorithm.compute("hilbert").get should equal ("h416")
+ Algorithm.compute("knuth").get should equal ("k530")
+ Algorithm.compute("lloyd").get should equal ("l300")
+ Algorithm.compute("lukasiewicz").get should equal ("l222")
+ Algorithm.compute("ashcroft").get should equal ("a261")
+ Algorithm.compute("tymczak").get should equal ("t522")
+ Algorithm.compute("pfister").get should equal ("p236")
+ Algorithm.compute("ellery").get should equal ("e460")
+ Algorithm.compute("ghosh").get should equal ("g200")
+ Algorithm.compute("heilbronn").get should equal ("h416")
+ Algorithm.compute("kant").get should equal ("k530")
+ Algorithm.compute("ladd").get should equal ("l300")
+ Algorithm.compute("lissajous").get should equal ("l222")
+ Algorithm.compute("fusedale").get should equal ("f234")
+ }
+ }
+ }
+ }
+ "SoundexAlgorithm companion object" should provide {
+ "pass-through compute method" should returns {
+ "same value as class" in {
+ SoundexAlgorithm.compute("abc").get should equal ("a120")
+ }
+ }
+ }
+}
+
+object SoundexAlgorithmSpec {
+ final private val Algorithm = SoundexAlgorithm()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala
new file mode 100755
index 0000000..9fc47d8
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala
@@ -0,0 +1,50 @@
+package com.rockymadden.stringmetric.phonetic
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class SoundexMetricSpec extends ScalaTest {
+ import SoundexMetricSpec.Metric
+
+ "SoundexMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "non-phonetic arguments" should returns {
+ "None" in {
+ Metric.compare("123", "123").isDefined should be (false)
+ Metric.compare("123", "").isDefined should be (false)
+ Metric.compare("", "123").isDefined should be (false)
+ }
+ }
+ "phonetically similar arguments" should returns {
+ "Boolean indicating true" in {
+ Metric.compare("robert", "rupert").get should be (true)
+ }
+ }
+ "phonetically dissimilar arguments" should returns {
+ "Boolean indicating false" in {
+ Metric.compare("robert", "rubin").get should be (false)
+ }
+ }
+ }
+ }
+ "SoundexMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ SoundexMetric.compare("robert", "rubin").get should be (false)
+ }
+ }
+ }
+}
+
+object SoundexMetricSpec {
+ final private val Metric = SoundexMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
new file mode 100755
index 0000000..5ddfc06
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala
@@ -0,0 +1,75 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class DiceSorensenMetricSpec extends ScalaTest {
+ import DiceSorensenMetricSpec.Metric
+
+ "DiceSorensenMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "")(1).isDefined should be (false)
+ Metric.compare("abc", "")(1).isDefined should be (false)
+ Metric.compare("", "xyz")(1).isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("abc", "abc")(1).get should be (1)
+ Metric.compare("abc", "abc")(2).get should be (1)
+ Metric.compare("abc", "abc")(3).get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz")(1).get should be (0)
+ Metric.compare("abc", "xyz")(2).get should be (0)
+ Metric.compare("abc", "xyz")(3).get should be (0)
+ }
+ }
+ "invalid arguments" should returns {
+ "None" in {
+ Metric.compare("n", "naght")(2).isDefined should be (false)
+ Metric.compare("night", "n")(2).isDefined should be (false)
+ Metric.compare("ni", "naght")(3).isDefined should be (false)
+ Metric.compare("night", "na")(3).isDefined should be (false)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("night", "nacht")(1).get should be (0.6)
+ Metric.compare("night", "naght")(1).get should be (0.8)
+ Metric.compare("context", "contact")(1).get should be (0.7142857142857143)
+
+ Metric.compare("night", "nacht")(2).get should be (0.25)
+ Metric.compare("night", "naght")(2).get should be (0.5)
+ Metric.compare("context", "contact")(2).get should be (0.5)
+ Metric.compare("contextcontext", "contact")(2).get should be (0.3157894736842105)
+ Metric.compare("context", "contactcontact")(2).get should be (0.3157894736842105)
+ Metric.compare("ht", "nacht")(2).get should be (0.4)
+ Metric.compare("xp", "nacht")(2).get should be (0)
+ Metric.compare("ht", "hththt")(2).get should be (0.3333333333333333)
+
+ Metric.compare("night", "nacht")(3).get should be (0)
+ Metric.compare("night", "naght")(3).get should be (0.3333333333333333)
+ Metric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+ }
+ "DiceSorensenMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ DiceSorensenMetric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+}
+
+object DiceSorensenMetricSpec {
+ private final val Metric = DiceSorensenMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala
new file mode 100755
index 0000000..c69d860
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala
@@ -0,0 +1,52 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class HammingMetricSpec extends ScalaTest {
+ import HammingMetricSpec.Metric
+
+ "HammingMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "abc").get should be (0)
+ Metric.compare("123", "123").get should be (0)
+ }
+ }
+ "unequal arguments" should returns {
+ "Int indicating distance" in {
+ Metric.compare("abc", "xyz").get should be (3)
+ Metric.compare("123", "456").get should be (3)
+ }
+ }
+ "valid arguments" should returns {
+ "Int indicating distance" in {
+ Metric.compare("toned", "roses").get should be (3)
+ Metric.compare("1011101", "1001001").get should be (2)
+ Metric.compare("2173896", "2233796").get should be (3)
+ }
+ }
+ }
+ }
+ "HammingMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ HammingMetric.compare("2173896", "2233796").get should be (3)
+ }
+ }
+ }
+}
+
+object HammingMetricSpec {
+ private final val Metric = HammingMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala
new file mode 100755
index 0000000..17bc3ef
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala
@@ -0,0 +1,77 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class JaccardMetricSpec extends ScalaTest {
+ import JaccardMetricSpec.Metric
+
+ "JaccardMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "")(1).isDefined should be (false)
+ Metric.compare("abc", "")(1).isDefined should be (false)
+ Metric.compare("", "xyz")(1).isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("abc", "abc")(1).get should be (1)
+ Metric.compare("abc", "abc")(2).get should be (1)
+ Metric.compare("abc", "abc")(3).get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz")(1).get should be (0)
+ Metric.compare("abc", "xyz")(2).get should be (0)
+ Metric.compare("abc", "xyz")(3).get should be (0)
+ }
+ }
+ "invalid arguments" should returns {
+ "None" in {
+ Metric.compare("n", "naght")(2).isDefined should be (false)
+ Metric.compare("night", "n")(2).isDefined should be (false)
+ Metric.compare("ni", "naght")(3).isDefined should be (false)
+ Metric.compare("night", "na")(3).isDefined should be (false)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("night", "nacht")(1).get should be (0.42857142857142855)
+ Metric.compare("night", "naght")(1).get should be (0.6666666666666666)
+ Metric.compare("context", "contact")(1).get should be (0.5555555555555556)
+
+ Metric.compare("night", "nacht")(2).get should be (0.14285714285714285)
+ Metric.compare("night", "naght")(2).get should be (0.3333333333333333)
+ Metric.compare("context", "contact")(2).get should be (0.3333333333333333)
+ Metric.compare("contextcontext", "contact")(2).get should be (0.1875)
+ Metric.compare("context", "contactcontact")(2).get should be (0.1875)
+ Metric.compare("ht", "nacht")(2).get should be (0.25)
+ Metric.compare("xp", "nacht")(2).get should be (0)
+ Metric.compare("ht", "hththt")(2).get should be (0.2)
+
+ Metric.compare("night", "nacht")(3).get should be (0)
+ Metric.compare("night", "naght")(3).get should be (0.2)
+ Metric.compare("context", "contact")(3).get should be (0.25)
+ }
+ }
+ }
+ }
+ "JaccardMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ JaccardMetric.compare("context", "contact")(3).get should be (0.25)
+ }
+ }
+ }
+}
+
+object JaccardMetricSpec {
+ private final val Metric = JaccardMetric()
+}
+
+
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala
new file mode 100755
index 0000000..00f4daf
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala
@@ -0,0 +1,66 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class JaroMetricSpec extends ScalaTest {
+ import JaroMetricSpec.Metric
+
+ "JaroMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("a", "a").get should be (1)
+ Metric.compare("abc", "abc").get should be (1)
+ Metric.compare("123", "123").get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz").get should be (0)
+ Metric.compare("123", "456").get should be (0)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("aa", "a").get should be (0.8333333333333334)
+ Metric.compare("a", "aa").get should be (0.8333333333333334)
+ Metric.compare("veryveryverylong", "v").get should be (0.6875)
+ Metric.compare("v", "veryveryverylong").get should be (0.6875)
+ Metric.compare("martha", "marhta").get should be (0.9444444444444445)
+ Metric.compare("dwayne", "duane").get should be (0.8222222222222223)
+ Metric.compare("dixon", "dicksonx").get should be (0.7666666666666666)
+ Metric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334)
+ Metric.compare("jones", "johnson").get should be (0.7904761904761904)
+ Metric.compare("henka", "henkan").get should be (0.9444444444444445)
+ Metric.compare("fvie", "ten").get should be (0)
+
+ Metric.compare("zac ephron", "zac efron").get should be >
+ Metric.compare("zac ephron", "kai ephron").get
+ Metric.compare("brittney spears", "britney spears").get should be >
+ Metric.compare("brittney spears", "brittney startzman").get
+ }
+ }
+ }
+ }
+ "JaroMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ JaroMetric.compare("fvie", "ten").get should be (0)
+ }
+ }
+ }
+}
+
+object JaroMetricSpec {
+ private final val Metric = JaroMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala
new file mode 100755
index 0000000..06421a8
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala
@@ -0,0 +1,66 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class JaroWinklerMetricSpec extends ScalaTest {
+ import JaroWinklerMetricSpec.Metric
+
+ "JaroWinklerMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("a", "a").get should be (1)
+ Metric.compare("abc", "abc").get should be (1)
+ Metric.compare("123", "123").get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz").get should be (0)
+ Metric.compare("123", "456").get should be (0)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("aa", "a").get should be (0.8500000000000001)
+ Metric.compare("a", "aa").get should be (0.8500000000000001)
+ Metric.compare("veryveryverylong", "v").get should be (0.71875)
+ Metric.compare("v", "veryveryverylong").get should be (0.71875)
+ Metric.compare("martha", "marhta").get should be (0.9611111111111111)
+ Metric.compare("dwayne", "duane").get should be (0.8400000000000001)
+ Metric.compare("dixon", "dicksonx").get should be (0.8133333333333332)
+ Metric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334)
+ Metric.compare("jones", "johnson").get should be (0.8323809523809523)
+ Metric.compare("henka", "henkan").get should be (0.9666666666666667)
+ Metric.compare("fvie", "ten").get should be (0)
+
+ Metric.compare("zac ephron", "zac efron").get should be >
+ Metric.compare("zac ephron", "kai ephron").get
+ Metric.compare("brittney spears", "britney spears").get should be >
+ Metric.compare("brittney spears", "brittney startzman").get
+ }
+ }
+ }
+ }
+ "JaroWinklerMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ JaroWinklerMetric.compare("fvie", "ten").get should be (0)
+ }
+ }
+ }
+}
+
+object JaroWinklerMetricSpec {
+ private final val Metric = JaroWinklerMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala
new file mode 100755
index 0000000..51de2ca
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala
@@ -0,0 +1,65 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class LevenshteinMetricSpec extends ScalaTest {
+ import LevenshteinMetricSpec.Metric
+
+ "LevenshteinMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "abc").get should be (0)
+ Metric.compare("123", "123").get should be (0)
+ }
+ }
+ "unequal arguments" should returns {
+ "Int indicating distance" in {
+ Metric.compare("abc", "xyz").get should be (3)
+ Metric.compare("123", "456").get should be (3)
+ }
+ }
+ "valid arguments" should returns {
+ "Int indicating distance" in {
+ Metric.compare("abc", "a").get should be (2)
+ Metric.compare("a", "abc").get should be (2)
+ Metric.compare("abc", "c").get should be (2)
+ Metric.compare("c", "abc").get should be (2)
+ Metric.compare("sitting", "kitten").get should be (3)
+ Metric.compare("kitten", "sitting").get should be (3)
+ Metric.compare("cake", "drake").get should be (2)
+ Metric.compare("drake", "cake").get should be (2)
+ Metric.compare("saturday", "sunday").get should be (3)
+ Metric.compare("sunday", "saturday").get should be (3)
+ Metric.compare("book", "back").get should be (2)
+ Metric.compare("dog", "fog").get should be (1)
+ Metric.compare("foq", "fog").get should be (1)
+ Metric.compare("fvg", "fog").get should be (1)
+ Metric.compare("encyclopedia", "encyclopediaz").get should be (1)
+ Metric.compare("encyclopediz", "encyclopediaz").get should be (1)
+ }
+ }
+ }
+ }
+ "LevenshteinMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ LevenshteinMetric.compare("fvg", "fog").get should be (1)
+ }
+ }
+ }
+}
+
+object LevenshteinMetricSpec {
+ private final val Metric = LevenshteinMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala
new file mode 100755
index 0000000..39d97e5
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala
@@ -0,0 +1,75 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class NGramMetricSpec extends ScalaTest {
+ import NGramMetricSpec.Metric
+
+ "NGramMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "")(1).isDefined should be (false)
+ Metric.compare("abc", "")(1).isDefined should be (false)
+ Metric.compare("", "xyz")(1).isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("abc", "abc")(1).get should be (1)
+ Metric.compare("abc", "abc")(2).get should be (1)
+ Metric.compare("abc", "abc")(3).get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz")(1).get should be (0)
+ Metric.compare("abc", "xyz")(2).get should be (0)
+ Metric.compare("abc", "xyz")(3).get should be (0)
+ }
+ }
+ "invalid arguments" should returns {
+ "None" in {
+ Metric.compare("n", "naght")(2).isDefined should be (false)
+ Metric.compare("night", "n")(2).isDefined should be (false)
+ Metric.compare("ni", "naght")(3).isDefined should be (false)
+ Metric.compare("night", "na")(3).isDefined should be (false)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("night", "nacht")(1).get should be (0.6)
+ Metric.compare("night", "naght")(1).get should be (0.8)
+ Metric.compare("context", "contact")(1).get should be (0.7142857142857143)
+
+ Metric.compare("night", "nacht")(2).get should be (0.25)
+ Metric.compare("night", "naght")(2).get should be (0.5)
+ Metric.compare("context", "contact")(2).get should be (0.5)
+ Metric.compare("contextcontext", "contact")(2).get should be (0.23076923076923078)
+ Metric.compare("context", "contactcontact")(2).get should be (0.23076923076923078)
+ Metric.compare("ht", "nacht")(2).get should be (0.25)
+ Metric.compare("xp", "nacht")(2).get should be (0)
+ Metric.compare("ht", "hththt")(2).get should be (0.2)
+
+ Metric.compare("night", "nacht")(3).get should be (0)
+ Metric.compare("night", "naght")(3).get should be (0.3333333333333333)
+ Metric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+ }
+ "NGramMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ NGramMetric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+}
+
+object NGramMetricSpec {
+ private final val Metric = NGramMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala
new file mode 100755
index 0000000..32c9650
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala
@@ -0,0 +1,77 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class OverlapMetricSpec extends ScalaTest {
+ import OverlapMetricSpec.Metric
+
+ "OverlapMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "")(1).isDefined should be (false)
+ Metric.compare("abc", "")(1).isDefined should be (false)
+ Metric.compare("", "xyz")(1).isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "1" in {
+ Metric.compare("abc", "abc")(1).get should be (1)
+ Metric.compare("abc", "abc")(2).get should be (1)
+ Metric.compare("abc", "abc")(3).get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "xyz")(1).get should be (0)
+ Metric.compare("abc", "xyz")(2).get should be (0)
+ Metric.compare("abc", "xyz")(3).get should be (0)
+ }
+ }
+ "invalid arguments" should returns {
+ "None" in {
+ Metric.compare("n", "naght")(2).isDefined should be (false)
+ Metric.compare("night", "n")(2).isDefined should be (false)
+ Metric.compare("ni", "naght")(3).isDefined should be (false)
+ Metric.compare("night", "na")(3).isDefined should be (false)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("bob", "bobman") (1).get should be (1)
+ Metric.compare("bob", "manbobman") (1).get should be (1)
+ Metric.compare("night", "nacht")(1).get should be (0.6)
+ Metric.compare("night", "naght")(1).get should be (0.8)
+ Metric.compare("context", "contact")(1).get should be (0.7142857142857143)
+
+ Metric.compare("night", "nacht")(2).get should be (0.25)
+ Metric.compare("night", "naght")(2).get should be (0.5)
+ Metric.compare("context", "contact")(2).get should be (0.5)
+ Metric.compare("contextcontext", "contact")(2).get should be (0.5)
+ Metric.compare("context", "contactcontact")(2).get should be (0.5)
+ Metric.compare("ht", "nacht")(2).get should be (1)
+ Metric.compare("xp", "nacht")(2).get should be (0)
+ Metric.compare("ht", "hththt")(2).get should be (1)
+
+ Metric.compare("night", "nacht")(3).get should be (0)
+ Metric.compare("night", "naght")(3).get should be (0.3333333333333333)
+ Metric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+ }
+ "OverlapMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ OverlapMetric.compare("context", "contact")(3).get should be (0.4)
+ }
+ }
+ }
+}
+
+object OverlapMetricSpec {
+ private final val Metric = OverlapMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala
new file mode 100755
index 0000000..638536f
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala
@@ -0,0 +1,56 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class RatcliffObershelpMetricSpec extends ScalaTest {
+ import RatcliffObershelpMetricSpec.Metric
+
+ "RatcliffObershelpMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "").isDefined should be (false)
+ Metric.compare("abc", "").isDefined should be (false)
+ Metric.compare("", "xyz").isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "abc").get should be (1)
+ Metric.compare("123", "123").get should be (1)
+ }
+ }
+ "unequal arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("abc", "xyz").get should be (0)
+ Metric.compare("123", "456").get should be (0)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("aleksander", "alexandre").get should be (0.7368421052631579)
+ Metric.compare("alexandre", "aleksander").get should be (0.7368421052631579)
+ Metric.compare("pennsylvania", "pencilvaneya").get should be (0.6666666666666666)
+ Metric.compare("pencilvaneya", "pennsylvania").get should be (0.6666666666666666)
+ Metric.compare("abcefglmn", "abefglmo").get should be (0.8235294117647058)
+ Metric.compare("abefglmo", "abcefglmn").get should be (0.8235294117647058)
+ }
+ }
+ }
+ }
+ "RatcliffObershelpMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ RatcliffObershelpMetric.compare("abefglmo", "abcefglmn").get should be (0.8235294117647058)
+ }
+ }
+ }
+}
+
+object RatcliffObershelpMetricSpec {
+ private final val Metric = RatcliffObershelpMetric()
+}
+
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala
new file mode 100755
index 0000000..9c46c89
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala
@@ -0,0 +1,64 @@
+package com.rockymadden.stringmetric.similarity
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class WeightedLevenshteinMetricSpec extends ScalaTest {
+ import WeightedLevenshteinMetricSpec.{Metric, Options}
+
+ "WeightedLevenshteinMetric" should provide {
+ "compare method" when passed {
+ "empty arguments" should returns {
+ "None" in {
+ Metric.compare("", "")(Options).isDefined should be (false)
+ Metric.compare("abc", "")(Options).isDefined should be (false)
+ Metric.compare("", "xyz")(Options).isDefined should be (false)
+ }
+ }
+ "equal arguments" should returns {
+ "0" in {
+ Metric.compare("abc", "abc")(Options).get should be (0)
+ Metric.compare("123", "123")(Options).get should be (0)
+ }
+ }
+ "unequal arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("abc", "xyz")(Options).get should be (3)
+ Metric.compare("123", "456")(Options).get should be (3)
+ }
+ }
+ "valid arguments" should returns {
+ "Double indicating distance" in {
+ Metric.compare("az", "z")(Options).get should be (10)
+ Metric.compare("z", "az")(Options).get should be (0.1)
+ Metric.compare("a", "z")(Options).get should be (1)
+ Metric.compare("z", "a")(Options).get should be (1)
+ Metric.compare("ab", "yz")(Options).get should be (2)
+ Metric.compare("yz", "ab")(Options).get should be (2)
+ Metric.compare("0", "0123456789")(Options).get should be (0.9)
+ Metric.compare("0123456789", "0")(Options).get should be (90)
+ Metric.compare("book", "back")(Options).get should be (2)
+ Metric.compare("back", "book")(Options).get should be (2)
+ Metric.compare("hosp", "hospital")(Options).get should be (0.4)
+ Metric.compare("hospital", "hosp")(Options).get should be (40)
+ Metric.compare("clmbs blvd", "columbus boulevard")(Options).get should be (0.8)
+ Metric.compare("columbus boulevard", "clmbs blvd")(Options).get should be (80)
+ }
+ }
+ }
+ }
+ "WeightedLevenshteinMetric companion object" should provide {
+ "pass-through compare method" should returns {
+ "same value as class" in {
+ WeightedLevenshteinMetric.compare("hospital", "hosp")(Options).get should be (40)
+ }
+ }
+ }
+}
+
+object WeightedLevenshteinMetricSpec {
+ private final val Options = Tuple3[BigDecimal, BigDecimal, BigDecimal](10, 0.1, 1)
+ private final val Metric = WeightedLevenshteinMetric()
+}
diff --git a/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala
new file mode 100755
index 0000000..56fdc13
--- /dev/null
+++ b/stringmetric-core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala
@@ -0,0 +1,69 @@
+package com.rockymadden.stringmetric.tokenization
+
+import com.rockymadden.stringmetric.ScalaTest
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+@RunWith(classOf[JUnitRunner])
+final class NGramTokenizerSpec extends ScalaTest {
+ import NGramTokenizerSpec.Tokenizer
+
+ "NGramTokenizer" should provide {
+ "tokenize method" when passed {
+ "empty argument" should returns {
+ "None" in {
+ Tokenizer.tokenize("")(1).isDefined should be (false)
+ }
+ }
+ "invalid n argument" should throws {
+ "IllegalArgumentException" in {
+ evaluating {
+ Tokenizer.tokenize("")(0).isDefined should be (false)
+ } should produce [IllegalArgumentException]
+
+ evaluating {
+ Tokenizer.tokenize("")(-1).isDefined should be (false)
+ } should produce [IllegalArgumentException]
+ }
+ }
+ "valid argument" should returns {
+ "Array[String]" in {
+ Tokenizer.tokenize("abcdefghijklmnopqrstuvwxyz")(1).get should equal (
+ Array(
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
+ "s", "t", "u", "v", "w", "x", "y", "z"
+ )
+ )
+ Tokenizer.tokenize("abcdefghijklmnopqrstuvwxyz")(2).get should equal (
+ Array(
+ "ab", "bc", "cd", "de", "ef", "fg", "gh", "hi", "ij", "jk", "kl", "lm", "mn", "no", "op",
+ "pq", "qr", "rs", "st", "tu", "uv", "vw", "wx", "xy", "yz"
+ )
+ )
+ Tokenizer.tokenize("abcdefghijklmnopqrstuvwxyz")(3).get should equal (
+ Array(
+ "abc", "bcd", "cde", "def", "efg", "fgh", "ghi", "hij", "ijk", "jkl", "klm", "lmn", "mno",
+ "nop", "opq", "pqr", "qrs", "rst", "stu", "tuv", "uvw", "vwx", "wxy", "xyz"
+ )
+ )
+ }
+ }
+ }
+ }
+ "NGramTokenizer companion object" should provide {
+ "pass-through tokenize method" should returns {
+ "same value as class" in {
+ NGramTokenizer.tokenize("abcdefghijklmnopqrstuvwxyz")(1).get should equal (
+ Array(
+ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
+ "s", "t", "u", "v", "w", "x", "y", "z"
+ )
+ )
+ }
+ }
+ }
+}
+
+object NGramTokenizerSpec {
+ private final val Tokenizer = NGramTokenizer()
+}