diff options
author | Rocky Madden <git@rockymadden.com> | 2013-12-28 11:49:33 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-12-28 11:49:33 -0700 |
commit | ef997c15f2ac152b53f05669f1d6bb9aa00aded7 (patch) | |
tree | 571f2eb996940b6f39dc7ab073bbc2d20ae9c93c /core/source/test/scala/com | |
parent | 001b756ff5fb88e295b0ff4e4ee89bf326a4f83e (diff) | |
download | stringmetric-ef997c15f2ac152b53f05669f1d6bb9aa00aded7.tar.gz stringmetric-ef997c15f2ac152b53f05669f1d6bb9aa00aded7.tar.bz2 stringmetric-ef997c15f2ac152b53f05669f1d6bb9aa00aded7.zip |
A more functional structure.
Diffstat (limited to 'core/source/test/scala/com')
38 files changed, 818 insertions, 1803 deletions
diff --git a/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala deleted file mode 100755 index e900f83..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/FilterDecoratedSpec.scala +++ /dev/null @@ -1,38 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala deleted file mode 100755 index 7ce0c24..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/StringAlgorithmSpec.scala +++ /dev/null @@ -1,59 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala deleted file mode 100755 index ca99bff..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/StringMetricSpec.scala +++ /dev/null @@ -1,141 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala deleted file mode 100755 index 8837c25..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/StringTokenizerSpec.scala +++ /dev/null @@ -1,23 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala deleted file mode 100755 index 1cce0c9..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala deleted file mode 100755 index 958c8ba..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiControlOnlyFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala deleted file mode 100755 index d86e7a5..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterFilterSpec.scala +++ /dev/null @@ -1,29 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala deleted file mode 100755 index edfdce6..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala deleted file mode 100755 index 7998e39..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterNumberOnlyFilterSpec.scala +++ /dev/null @@ -1,35 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala deleted file mode 100755 index d134792..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiLetterOnlyFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala deleted file mode 100755 index 7c24d45..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala deleted file mode 100755 index db49d25..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiNumberOnlyFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala deleted file mode 100755 index 759db3d..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSpaceFilterSpec.scala +++ /dev/null @@ -1,37 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala deleted file mode 100755 index 99be533..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolFilterSpec.scala +++ /dev/null @@ -1,31 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala deleted file mode 100755 index c6f1899..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/AsciiSymbolOnlyFilterSpec.scala +++ /dev/null @@ -1,33 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala deleted file mode 100755 index a04a0ae..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/IgnoreAsciiLetterCaseFilterSpec.scala +++ /dev/null @@ -1,41 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala deleted file mode 100755 index 132156b..0000000 --- a/core/source/test/scala/com/rockymadden/stringmetric/filter/StringFilterDelegateSpec.scala +++ /dev/null @@ -1,31 +0,0 @@ -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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala index 1f904d5..e29a9ae 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneAlgorithmSpec.scala @@ -6,221 +6,208 @@ 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) + MetaphoneAlgorithm.compute("").isDefined should be (false) } } "non-phonetic argument" should returns { "None" in { - Algorithm.compute("123").isDefined should be (false) + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("z").get should equal ("s") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("y").isDefined should be (false) + MetaphoneAlgorithm.compute("zy").get should equal ("s") + MetaphoneAlgorithm.compute("zyz").get should equal ("ss") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("x").get should equal ("s") + MetaphoneAlgorithm.compute("zx").get should equal ("sks") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("w").isDefined should be (false) + MetaphoneAlgorithm.compute("zw").get should equal ("s") + MetaphoneAlgorithm.compute("zwz").get should equal ("ss") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("v").get should equal ("f") + MetaphoneAlgorithm.compute("zv").get should equal ("sf") + MetaphoneAlgorithm.compute("zvz").get should equal ("sfs") // u - Algorithm.compute("u").get should equal ("u") - Algorithm.compute("zu").get should equal ("s") + MetaphoneAlgorithm.compute("u").get should equal ("u") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("t").get should equal ("t") + MetaphoneAlgorithm.compute("ztiaz").get should equal ("sxs") + MetaphoneAlgorithm.compute("ztioz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zthz").get should equal ("s0s") + MetaphoneAlgorithm.compute("ztchz").get should equal ("sxs") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("s").get should equal ("s") + MetaphoneAlgorithm.compute("zshz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zsioz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zsiaz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zs").get should equal ("ss") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("r").get should equal ("r") + MetaphoneAlgorithm.compute("zr").get should equal ("sr") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("q").get should equal ("k") + MetaphoneAlgorithm.compute("zq").get should equal ("sk") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("p").get should equal ("p") + MetaphoneAlgorithm.compute("zp").get should equal ("sp") + MetaphoneAlgorithm.compute("zph").get should equal ("sf") + MetaphoneAlgorithm.compute("zpz").get should equal ("sps") // o - Algorithm.compute("o").get should equal ("o") - Algorithm.compute("zo").get should equal ("s") + MetaphoneAlgorithm.compute("o").get should equal ("o") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("n").get should equal ("n") + MetaphoneAlgorithm.compute("zn").get should equal ("sn") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("m").get should equal ("m") + MetaphoneAlgorithm.compute("zm").get should equal ("sm") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("l").get should equal ("l") + MetaphoneAlgorithm.compute("zl").get should equal ("sl") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("k").get should equal ("k") + MetaphoneAlgorithm.compute("zk").get should equal ("sk") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("j").get should equal ("j") + MetaphoneAlgorithm.compute("zj").get should equal ("sj") + MetaphoneAlgorithm.compute("zjz").get should equal ("sjs") // i - Algorithm.compute("i").get should equal ("i") - Algorithm.compute("zi").get should equal ("s") + MetaphoneAlgorithm.compute("i").get should equal ("i") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("h").get should equal ("h") // php wrongly says nothing + MetaphoneAlgorithm.compute("zh").get should equal ("sh") // php wrongly says s + MetaphoneAlgorithm.compute("zah").get should equal ("s") + MetaphoneAlgorithm.compute("zchh").get should equal ("sx") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("g").get should equal ("k") + MetaphoneAlgorithm.compute("zg").get should equal ("sk") + MetaphoneAlgorithm.compute("zgh").get should equal ("skh") // php wrongly says sf + MetaphoneAlgorithm.compute("zghz").get should equal ("shs") // php wrongly says sfs + MetaphoneAlgorithm.compute("zgha").get should equal ("sh") // php wrongly says sf others wrongly say skh + MetaphoneAlgorithm.compute("zgn").get should equal ("sn") + MetaphoneAlgorithm.compute("zgns").get should equal ("skns") + MetaphoneAlgorithm.compute("zgned").get should equal ("snt") // others wrongly says sknt + MetaphoneAlgorithm.compute("zgneds").get should equal ("sknts") // php wrongly says snts + MetaphoneAlgorithm.compute("zgi").get should equal ("sj") + MetaphoneAlgorithm.compute("zgiz").get should equal ("sjs") + MetaphoneAlgorithm.compute("zge").get should equal ("sj") + MetaphoneAlgorithm.compute("zgez").get should equal ("sjs") + MetaphoneAlgorithm.compute("zgy").get should equal ("sj") + MetaphoneAlgorithm.compute("zgyz").get should equal ("sjs") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("f").get should equal ("f") + MetaphoneAlgorithm.compute("zf").get should equal ("sf") + MetaphoneAlgorithm.compute("zfz").get should equal ("sfs") // e - Algorithm.compute("e").get should equal ("e") - Algorithm.compute("ze").get should equal ("s") + MetaphoneAlgorithm.compute("e").get should equal ("e") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("d").get should equal ("t") + MetaphoneAlgorithm.compute("fudge").get should equal ("fjj") // php wrongly says fj + MetaphoneAlgorithm.compute("dodgy").get should equal ("tjj") // php wrongly says tj others wrongly say tjjy + MetaphoneAlgorithm.compute("dodgi").get should equal ("tjj") // php wrongly says tj + MetaphoneAlgorithm.compute("zd").get should equal ("st") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("c").get should equal ("k") + MetaphoneAlgorithm.compute("zcia").get should equal ("sx") + MetaphoneAlgorithm.compute("zciaz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zch").get should equal ("sx") + MetaphoneAlgorithm.compute("zchz").get should equal ("sxs") + MetaphoneAlgorithm.compute("zci").get should equal ("ss") + MetaphoneAlgorithm.compute("zciz").get should equal ("sss") + MetaphoneAlgorithm.compute("zce").get should equal ("ss") + MetaphoneAlgorithm.compute("zcez").get should equal ("sss") + MetaphoneAlgorithm.compute("zcy").get should equal ("ss") + MetaphoneAlgorithm.compute("zcyz").get should equal ("sss") + MetaphoneAlgorithm.compute("zsci").get should equal ("ss") + MetaphoneAlgorithm.compute("zsciz").get should equal ("sss") + MetaphoneAlgorithm.compute("zsce").get should equal ("ss") + MetaphoneAlgorithm.compute("zscez").get should equal ("sss") + MetaphoneAlgorithm.compute("zscy").get should equal ("ss") + MetaphoneAlgorithm.compute("zscyz").get should equal ("sss") + MetaphoneAlgorithm.compute("zsch").get should equal ("sskh") // php wrongly says ssx + MetaphoneAlgorithm.compute("zc").get should equal ("sk") + MetaphoneAlgorithm.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") + MetaphoneAlgorithm.compute("b").get should equal ("b") + MetaphoneAlgorithm.compute("zb").get should equal ("sb") + MetaphoneAlgorithm.compute("zbz").get should equal ("sbs") + MetaphoneAlgorithm.compute("zmb").get should equal ("sm") // a - Algorithm.compute("a").get should equal ("a") - Algorithm.compute("za").get should equal ("s") + MetaphoneAlgorithm.compute("a").get should equal ("a") + MetaphoneAlgorithm.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.compute("dumb").get should equal ("tm") + MetaphoneAlgorithm.compute("smith").get should equal ("sm0") + MetaphoneAlgorithm.compute("school").get should equal ("skhl") // php wrongly says sxl + MetaphoneAlgorithm.compute("merci").get should equal ("mrs") + MetaphoneAlgorithm.compute("cool").get should equal ("kl") + MetaphoneAlgorithm.compute("aebersold").get should equal ("ebrslt") + MetaphoneAlgorithm.compute("gnagy").get should equal ("nj") + MetaphoneAlgorithm.compute("knuth").get should equal ("n0") + MetaphoneAlgorithm.compute("pniewski").get should equal ("nsk") + MetaphoneAlgorithm.compute("wright").get should equal ("rht") // php wrongly says rft + MetaphoneAlgorithm.compute("phone").get should equal ("fn") + MetaphoneAlgorithm.compute("aggregate").get should equal ("akrkt") + MetaphoneAlgorithm.compute("accuracy").get should equal ("akkrs") + MetaphoneAlgorithm.compute("encyclopedia").get should equal ("ensklpt") + MetaphoneAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hnrfkblttnttbs") + MetaphoneAlgorithm.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala index 9a029d8..94ff5db 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/MetaphoneMetricSpec.scala @@ -6,49 +6,36 @@ 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) + MetaphoneMetric.compare("", "").isDefined should be (false) + MetaphoneMetric.compare("abc", "").isDefined should be (false) + MetaphoneMetric.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) + MetaphoneMetric.compare("123", "123").isDefined should be (false) + MetaphoneMetric.compare("123", "").isDefined should be (false) + MetaphoneMetric.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) + MetaphoneMetric.compare("dumb", "dum").get should be (true) + MetaphoneMetric.compare("smith", "smeth").get should be (true) + MetaphoneMetric.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.compare("dumb", "gum").get should be (false) + MetaphoneMetric.compare("smith", "kiss").get should be (false) + MetaphoneMetric.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala index 6a0f113..dea95b8 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisAlgorithmSpec.scala @@ -6,199 +6,186 @@ 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) + NysiisAlgorithm.compute("").isDefined should be (false) } } "non-phonetic argument" should returns { "None" in { - Algorithm.compute("123").isDefined should be (false) + NysiisAlgorithm.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") + NysiisAlgorithm.compute("a").get should equal ("a") + NysiisAlgorithm.compute("aa").get should equal ("a") // b - Algorithm.compute("b").get should equal ("b") - Algorithm.compute("bb").get should equal ("bb") + NysiisAlgorithm.compute("b").get should equal ("b") + NysiisAlgorithm.compute("bb").get should equal ("bb") // c - Algorithm.compute("c").get should equal ("c") - Algorithm.compute("cc").get should equal ("cc") + NysiisAlgorithm.compute("c").get should equal ("c") + NysiisAlgorithm.compute("cc").get should equal ("cc") // d - Algorithm.compute("d").get should equal ("d") - Algorithm.compute("dd").get should equal ("dd") + NysiisAlgorithm.compute("d").get should equal ("d") + NysiisAlgorithm.compute("dd").get should equal ("dd") // e - Algorithm.compute("e").get should equal ("e") - Algorithm.compute("ee").get should equal ("y") + NysiisAlgorithm.compute("e").get should equal ("e") + NysiisAlgorithm.compute("ee").get should equal ("y") // f - Algorithm.compute("f").get should equal ("f") - Algorithm.compute("ff").get should equal ("ff") + NysiisAlgorithm.compute("f").get should equal ("f") + NysiisAlgorithm.compute("ff").get should equal ("ff") // g - Algorithm.compute("g").get should equal ("g") - Algorithm.compute("gg").get should equal ("gg") + NysiisAlgorithm.compute("g").get should equal ("g") + NysiisAlgorithm.compute("gg").get should equal ("gg") // h - Algorithm.compute("h").get should equal ("h") - Algorithm.compute("hh").get should equal ("hh") + NysiisAlgorithm.compute("h").get should equal ("h") + NysiisAlgorithm.compute("hh").get should equal ("hh") // i - Algorithm.compute("i").get should equal ("i") - Algorithm.compute("ii").get should equal ("i") + NysiisAlgorithm.compute("i").get should equal ("i") + NysiisAlgorithm.compute("ii").get should equal ("i") // j - Algorithm.compute("j").get should equal ("j") - Algorithm.compute("jj").get should equal ("jj") + NysiisAlgorithm.compute("j").get should equal ("j") + NysiisAlgorithm.compute("jj").get should equal ("jj") // k - Algorithm.compute("k").get should equal ("c") - Algorithm.compute("kk").get should equal ("cc") + NysiisAlgorithm.compute("k").get should equal ("c") + NysiisAlgorithm.compute("kk").get should equal ("cc") // l - Algorithm.compute("l").get should equal ("l") - Algorithm.compute("ll").get should equal ("ll") + NysiisAlgorithm.compute("l").get should equal ("l") + NysiisAlgorithm.compute("ll").get should equal ("ll") // m - Algorithm.compute("m").get should equal ("m") - Algorithm.compute("mm").get should equal ("mn") + NysiisAlgorithm.compute("m").get should equal ("m") + NysiisAlgorithm.compute("mm").get should equal ("mn") // n - Algorithm.compute("n").get should equal ("n") - Algorithm.compute("nn").get should equal ("nn") + NysiisAlgorithm.compute("n").get should equal ("n") + NysiisAlgorithm.compute("nn").get should equal ("nn") // o - Algorithm.compute("o").get should equal ("o") - Algorithm.compute("oo").get should equal ("o") + NysiisAlgorithm.compute("o").get should equal ("o") + NysiisAlgorithm.compute("oo").get should equal ("o") // p - Algorithm.compute("p").get should equal ("p") - Algorithm.compute("pp").get should equal ("pp") + NysiisAlgorithm.compute("p").get should equal ("p") + NysiisAlgorithm.compute("pp").get should equal ("pp") // q - Algorithm.compute("q").get should equal ("q") - Algorithm.compute("qq").get should equal ("qg") + NysiisAlgorithm.compute("q").get should equal ("q") + NysiisAlgorithm.compute("qq").get should equal ("qg") // r - Algorithm.compute("r").get should equal ("r") - Algorithm.compute("rr").get should equal ("rr") + NysiisAlgorithm.compute("r").get should equal ("r") + NysiisAlgorithm.compute("rr").get should equal ("rr") // s - Algorithm.compute("s").get should equal ("s") - Algorithm.compute("ss").get should equal ("s") + NysiisAlgorithm.compute("s").get should equal ("s") + NysiisAlgorithm.compute("ss").get should equal ("s") // t - Algorithm.compute("t").get should equal ("t") - Algorithm.compute("tt").get should equal ("tt") + NysiisAlgorithm.compute("t").get should equal ("t") + NysiisAlgorithm.compute("tt").get should equal ("tt") // u - Algorithm.compute("u").get should equal ("u") - Algorithm.compute("uu").get should equal ("u") + NysiisAlgorithm.compute("u").get should equal ("u") + NysiisAlgorithm.compute("uu").get should equal ("u") // v - Algorithm.compute("v").get should equal ("v") - Algorithm.compute("vv").get should equal ("vv") + NysiisAlgorithm.compute("v").get should equal ("v") + NysiisAlgorithm.compute("vv").get should equal ("vv") // w - Algorithm.compute("w").get should equal ("w") - Algorithm.compute("ww").get should equal ("ww") + NysiisAlgorithm.compute("w").get should equal ("w") + NysiisAlgorithm.compute("ww").get should equal ("ww") // x - Algorithm.compute("x").get should equal ("x") - Algorithm.compute("xx").get should equal ("xx") + NysiisAlgorithm.compute("x").get should equal ("x") + NysiisAlgorithm.compute("xx").get should equal ("xx") // y - Algorithm.compute("y").get should equal ("y") - Algorithm.compute("yy").get should equal ("yy") + NysiisAlgorithm.compute("y").get should equal ("y") + NysiisAlgorithm.compute("yy").get should equal ("yy") // z - Algorithm.compute("z").get should equal ("z") - Algorithm.compute("zz").get should equal ("z") + NysiisAlgorithm.compute("z").get should equal ("z") + NysiisAlgorithm.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 + NysiisAlgorithm.compute("mac").get should equal ("mc") + NysiisAlgorithm.compute("kn").get should equal ("nn") + NysiisAlgorithm.compute("k").get should equal ("c") + NysiisAlgorithm.compute("ph").get should equal ("ff") + NysiisAlgorithm.compute("pf").get should equal ("ff") + NysiisAlgorithm.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") + NysiisAlgorithm.compute("ee").get should equal ("y") + NysiisAlgorithm.compute("ie").get should equal ("y") + NysiisAlgorithm.compute("dt").get should equal ("d") + NysiisAlgorithm.compute("rt").get should equal ("d") + NysiisAlgorithm.compute("rd").get should equal ("d") + NysiisAlgorithm.compute("nt").get should equal ("d") + NysiisAlgorithm.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") + NysiisAlgorithm.compute("eev").get should equal ("eaf") + NysiisAlgorithm.compute("zev").get should equal ("zaf") + NysiisAlgorithm.compute("kkn").get should equal ("cn") + NysiisAlgorithm.compute("sschn").get should equal ("ssn") + NysiisAlgorithm.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") + NysiisAlgorithm.compute("macdonald").get should equal ("mcdanald") + NysiisAlgorithm.compute("phone").get should equal ("ffan") + NysiisAlgorithm.compute("aggregate").get should equal ("agragat") + NysiisAlgorithm.compute("accuracy").get should equal ("acaracy") + NysiisAlgorithm.compute("encyclopedia").get should equal ("encyclapad") + NysiisAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab") + NysiisAlgorithm.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.compute("macintosh").get should equal ("mcant") + NysiisAlgorithm.compute("knuth").get should equal ("nnat") + NysiisAlgorithm.compute("koehn").get should equal ("can") // dropby wrongly says c + NysiisAlgorithm.compute("phillipson").get should equal ("ffalapsan") + NysiisAlgorithm.compute("pfeister").get should equal ("ffastar") + NysiisAlgorithm.compute("schoenhoeft").get should equal ("ssanaft") + NysiisAlgorithm.compute("mckee").get should equal ("mcy") + NysiisAlgorithm.compute("heitschmedt").get should equal ("hatsnad") + NysiisAlgorithm.compute("bart").get should equal ("bad") + NysiisAlgorithm.compute("hurd").get should equal ("had") + NysiisAlgorithm.compute("hunt").get should equal ("had") + NysiisAlgorithm.compute("westerlund").get should equal ("wastarlad") + NysiisAlgorithm.compute("casstevens").get should equal ("castafan") + NysiisAlgorithm.compute("vasquez").get should equal ("vasg") + NysiisAlgorithm.compute("frazier").get should equal ("frasar") + NysiisAlgorithm.compute("bowman").get should equal ("banan") + NysiisAlgorithm.compute("mcknight").get should equal ("mcnagt") + NysiisAlgorithm.compute("rickert").get should equal ("racad") + NysiisAlgorithm.compute("deutsch").get should equal ("dat") // dropby wrongly says dats + NysiisAlgorithm.compute("westphal").get should equal ("wastfal") + NysiisAlgorithm.compute("shriver").get should equal ("shravar") + NysiisAlgorithm.compute("kuhl").get should equal ("cal") // dropby wrongly says c + NysiisAlgorithm.compute("rawson").get should equal ("rasan") + NysiisAlgorithm.compute("jiles").get should equal ("jal") + NysiisAlgorithm.compute("carraway").get should equal ("caray") + NysiisAlgorithm.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala index c6929a2..7e52101 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/NysiisMetricSpec.scala @@ -6,45 +6,32 @@ 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) + NysiisMetric.compare("", "").isDefined should be (false) + NysiisMetric.compare("abc", "").isDefined should be (false) + NysiisMetric.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) + NysiisMetric.compare("123", "123").isDefined should be (false) + NysiisMetric.compare("123", "").isDefined should be (false) + NysiisMetric.compare("", "123").isDefined should be (false) } } "phonetically similar arguments" should returns { "Boolean indicating true" in { - Metric.compare("ham", "hum").get should be (true) + NysiisMetric.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.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala index 1298d2d..eaa09ce 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisAlgorithmSpec.scala @@ -6,216 +6,203 @@ 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) + RefinedNysiisAlgorithm.compute("").isDefined should be (false) } } "non-phonetic argument" should returns { "None" in { - Algorithm.compute("123").isDefined should be (false) + RefinedNysiisAlgorithm.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") + RefinedNysiisAlgorithm.compute("a").get should equal ("a") + RefinedNysiisAlgorithm.compute("aa").get should equal ("a") // b - Algorithm.compute("b").get should equal ("b") - Algorithm.compute("bb").get should equal ("b") + RefinedNysiisAlgorithm.compute("b").get should equal ("b") + RefinedNysiisAlgorithm.compute("bb").get should equal ("b") // c - Algorithm.compute("c").get should equal ("c") - Algorithm.compute("cc").get should equal ("c") + RefinedNysiisAlgorithm.compute("c").get should equal ("c") + RefinedNysiisAlgorithm.compute("cc").get should equal ("c") // d - Algorithm.compute("d").get should equal ("d") - Algorithm.compute("dd").get should equal ("d") + RefinedNysiisAlgorithm.compute("d").get should equal ("d") + RefinedNysiisAlgorithm.compute("dd").get should equal ("d") // e - Algorithm.compute("e").get should equal ("e") - Algorithm.compute("ee").get should equal ("y") + RefinedNysiisAlgorithm.compute("e").get should equal ("e") + RefinedNysiisAlgorithm.compute("ee").get should equal ("y") // f - Algorithm.compute("f").get should equal ("f") - Algorithm.compute("ff").get should equal ("f") + RefinedNysiisAlgorithm.compute("f").get should equal ("f") + RefinedNysiisAlgorithm.compute("ff").get should equal ("f") // g - Algorithm.compute("g").get should equal ("g") - Algorithm.compute("gg").get should equal ("g") + RefinedNysiisAlgorithm.compute("g").get should equal ("g") + RefinedNysiisAlgorithm.compute("gg").get should equal ("g") // h - Algorithm.compute("h").get should equal ("h") - Algorithm.compute("hh").get should equal ("h") + RefinedNysiisAlgorithm.compute("h").get should equal ("h") + RefinedNysiisAlgorithm.compute("hh").get should equal ("h") // i - Algorithm.compute("i").get should equal ("i") - Algorithm.compute("ii").get should equal ("i") + RefinedNysiisAlgorithm.compute("i").get should equal ("i") + RefinedNysiisAlgorithm.compute("ii").get should equal ("i") // j - Algorithm.compute("j").get should equal ("j") - Algorithm.compute("jj").get should equal ("j") + RefinedNysiisAlgorithm.compute("j").get should equal ("j") + RefinedNysiisAlgorithm.compute("jj").get should equal ("j") // k - Algorithm.compute("k").get should equal ("c") - Algorithm.compute("kk").get should equal ("c") + RefinedNysiisAlgorithm.compute("k").get should equal ("c") + RefinedNysiisAlgorithm.compute("kk").get should equal ("c") // l - Algorithm.compute("l").get should equal ("l") - Algorithm.compute("ll").get should equal ("l") + RefinedNysiisAlgorithm.compute("l").get should equal ("l") + RefinedNysiisAlgorithm.compute("ll").get should equal ("l") // m - Algorithm.compute("m").get should equal ("m") - Algorithm.compute("mm").get should equal ("mn") + RefinedNysiisAlgorithm.compute("m").get should equal ("m") + RefinedNysiisAlgorithm.compute("mm").get should equal ("mn") // n - Algorithm.compute("n").get should equal ("n") - Algorithm.compute("nn").get should equal ("n") + RefinedNysiisAlgorithm.compute("n").get should equal ("n") + RefinedNysiisAlgorithm.compute("nn").get should equal ("n") // o - Algorithm.compute("o").get should equal ("o") - Algorithm.compute("oo").get should equal ("o") + RefinedNysiisAlgorithm.compute("o").get should equal ("o") + RefinedNysiisAlgorithm.compute("oo").get should equal ("o") // p - Algorithm.compute("p").get should equal ("p") - Algorithm.compute("pp").get should equal ("p") + RefinedNysiisAlgorithm.compute("p").get should equal ("p") + RefinedNysiisAlgorithm.compute("pp").get should equal ("p") // q - Algorithm.compute("q").get should equal ("q") - Algorithm.compute("qq").get should equal ("qg") + RefinedNysiisAlgorithm.compute("q").get should equal ("q") + RefinedNysiisAlgorithm.compute("qq").get should equal ("qg") // r - Algorithm.compute("r").get should equal ("r") - Algorithm.compute("rr").get should equal ("r") + RefinedNysiisAlgorithm.compute("r").get should equal ("r") + RefinedNysiisAlgorithm.compute("rr").get should equal ("r") // s - Algorithm.compute("s").get should equal ("s") - Algorithm.compute("ss").get should equal ("s") + RefinedNysiisAlgorithm.compute("s").get should equal ("s") + RefinedNysiisAlgorithm.compute("ss").get should equal ("s") // t - Algorithm.compute("t").get should equal ("t") - Algorithm.compute("tt").get should equal ("t") + RefinedNysiisAlgorithm.compute("t").get should equal ("t") + RefinedNysiisAlgorithm.compute("tt").get should equal ("t") // u - Algorithm.compute("u").get should equal ("u") - Algorithm.compute("uu").get should equal ("u") + RefinedNysiisAlgorithm.compute("u").get should equal ("u") + RefinedNysiisAlgorithm.compute("uu").get should equal ("u") // v - Algorithm.compute("v").get should equal ("v") - Algorithm.compute("vv").get should equal ("v") + RefinedNysiisAlgorithm.compute("v").get should equal ("v") + RefinedNysiisAlgorithm.compute("vv").get should equal ("v") // w - Algorithm.compute("w").get should equal ("w") - Algorithm.compute("ww").get should equal ("w") + RefinedNysiisAlgorithm.compute("w").get should equal ("w") + RefinedNysiisAlgorithm.compute("ww").get should equal ("w") // x - Algorithm.compute("x").get should equal ("x") - Algorithm.compute("xx").get should equal ("x") + RefinedNysiisAlgorithm.compute("x").get should equal ("x") + RefinedNysiisAlgorithm.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") + RefinedNysiisAlgorithm.compute("y").get should equal ("y") + RefinedNysiisAlgorithm.compute("yy").get should equal ("y") + RefinedNysiisAlgorithm.compute("ybyb").get should equal ("ybab") // z - Algorithm.compute("z").get should equal ("z") - Algorithm.compute("zz").get should equal ("z") + RefinedNysiisAlgorithm.compute("z").get should equal ("z") + RefinedNysiisAlgorithm.compute("zz").get should equal ("z") // Head cases. - Algorithm.compute("mac").get should equal ("mc") - Algorithm.compute("pf").get should equal ("f") + RefinedNysiisAlgorithm.compute("mac").get should equal ("mc") + RefinedNysiisAlgorithm.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") + RefinedNysiisAlgorithm.compute("ix").get should equal ("ic") + RefinedNysiisAlgorithm.compute("ex").get should equal ("ec") + RefinedNysiisAlgorithm.compute("ye").get should equal ("y") + RefinedNysiisAlgorithm.compute("ee").get should equal ("y") + RefinedNysiisAlgorithm.compute("ie").get should equal ("y") + RefinedNysiisAlgorithm.compute("dt").get should equal ("d") + RefinedNysiisAlgorithm.compute("rt").get should equal ("d") + RefinedNysiisAlgorithm.compute("rd").get should equal ("d") + RefinedNysiisAlgorithm.compute("nt").get should equal ("d") + RefinedNysiisAlgorithm.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") + RefinedNysiisAlgorithm.compute("bevb").get should equal ("bafb") + RefinedNysiisAlgorithm.compute("bghtb").get should equal ("bgtb") + RefinedNysiisAlgorithm.compute("bdgb").get should equal ("bgb") + RefinedNysiisAlgorithm.compute("bphb").get should equal ("bfb") + RefinedNysiisAlgorithm.compute("bknb").get should equal ("bnb") + RefinedNysiisAlgorithm.compute("bshb").get should equal ("bsb") + RefinedNysiisAlgorithm.compute("bschb").get should equal ("bsb") + RefinedNysiisAlgorithm.compute("bywb").get should equal ("bab") + RefinedNysiisAlgorithm.compute("byw").get should equal ("by") + RefinedNysiisAlgorithm.compute("ywb").get should equal ("yb") + RefinedNysiisAlgorithm.compute("bwrb").get should equal ("brb") // Transcode cases. - Algorithm.compute("bay").get should equal ("by") + RefinedNysiisAlgorithm.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") + RefinedNysiisAlgorithm.compute("macdonald").get should equal ("mcdanald") + RefinedNysiisAlgorithm.compute("phone").get should equal ("fan") + RefinedNysiisAlgorithm.compute("aggregate").get should equal ("agragat") + RefinedNysiisAlgorithm.compute("accuracy").get should equal ("acaracy") + RefinedNysiisAlgorithm.compute("encyclopedia").get should equal ("encaclapad") + RefinedNysiisAlgorithm.compute("honorificabilitudinitatibus").get should equal ("hanarafacabalatadanatatab") + RefinedNysiisAlgorithm.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.compute("edwards").get should equal ("edwad") + RefinedNysiisAlgorithm.compute("parez").get should equal ("par") + RefinedNysiisAlgorithm.compute("macintosh").get should equal ("mcantas") + RefinedNysiisAlgorithm.compute("phillipson").get should equal ("falapsan") + RefinedNysiisAlgorithm.compute("haddix").get should equal ("hadac") + RefinedNysiisAlgorithm.compute("essex").get should equal ("esac") + RefinedNysiisAlgorithm.compute("moye").get should equal ("my") + RefinedNysiisAlgorithm.compute("mckee").get should equal ("mcy") + RefinedNysiisAlgorithm.compute("mackie").get should equal ("mcy") + RefinedNysiisAlgorithm.compute("heitschmidt").get should equal ("hatsnad") + RefinedNysiisAlgorithm.compute("bart").get should equal ("bad") + RefinedNysiisAlgorithm.compute("hurd").get should equal ("had") + RefinedNysiisAlgorithm.compute("hunt").get should equal ("had") + RefinedNysiisAlgorithm.compute("westerlund").get should equal ("wastarlad") + RefinedNysiisAlgorithm.compute("evers").get should equal ("evar") + RefinedNysiisAlgorithm.compute("devito").get should equal ("dafat") + RefinedNysiisAlgorithm.compute("rawson").get should equal ("rasan") + RefinedNysiisAlgorithm.compute("shoulders").get should equal ("saldar") + RefinedNysiisAlgorithm.compute("leighton").get should equal ("lagtan") + RefinedNysiisAlgorithm.compute("wooldridge").get should equal ("waldrag") + RefinedNysiisAlgorithm.compute("oliphant").get should equal ("olafad") + RefinedNysiisAlgorithm.compute("hatchett").get should equal ("hatcat") + RefinedNysiisAlgorithm.compute("mcknight").get should equal ("mcnagt") + RefinedNysiisAlgorithm.compute("rickert").get should equal ("racad") + RefinedNysiisAlgorithm.compute("bowman").get should equal ("banan") + RefinedNysiisAlgorithm.compute("vasquez").get should equal ("vasg") + RefinedNysiisAlgorithm.compute("bashaw").get should equal ("bas") + RefinedNysiisAlgorithm.compute("schoenhoeft").get should equal ("sanaft") // dropby wrongly says scanaft + RefinedNysiisAlgorithm.compute("heywood").get should equal ("had") + RefinedNysiisAlgorithm.compute("hayman").get should equal ("hanan") + RefinedNysiisAlgorithm.compute("seawright").get should equal ("saragt") + RefinedNysiisAlgorithm.compute("kratzer").get should equal ("cratsar") + RefinedNysiisAlgorithm.compute("canaday").get should equal ("canady") + RefinedNysiisAlgorithm.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala index ca9d2ec..8ac87e1 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedNysiisMetricSpec.scala @@ -6,45 +6,32 @@ 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) + RefinedNysiisMetric.compare("", "").isDefined should be (false) + RefinedNysiisMetric.compare("abc", "").isDefined should be (false) + RefinedNysiisMetric.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) + RefinedNysiisMetric.compare("123", "123").isDefined should be (false) + RefinedNysiisMetric.compare("123", "").isDefined should be (false) + RefinedNysiisMetric.compare("", "123").isDefined should be (false) } } "phonetically similar arguments" should returns { "Boolean indicating true" in { - Metric.compare("ham", "hum").get should be (true) + RefinedNysiisMetric.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.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala index 254bf06..cc6dc37 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexAlgorithmSpec.scala @@ -6,170 +6,157 @@ 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) + RefinedSoundexAlgorithm.compute("").isDefined should be (false) } } "non-phonetic argument" should returns { "None" in { - Algorithm.compute("123").isDefined should be (false) + RefinedSoundexAlgorithm.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") + RefinedSoundexAlgorithm.compute("a").get should equal ("a0") + RefinedSoundexAlgorithm.compute("aa").get should equal ("a0") // b - Algorithm.compute("b").get should equal ("b1") - Algorithm.compute("bb").get should equal ("b1") + RefinedSoundexAlgorithm.compute("b").get should equal ("b1") + RefinedSoundexAlgorithm.compute("bb").get should equal ("b1") // c - Algorithm.compute("c").get should equal ("c3") - Algorithm.compute("cc").get should equal ("c3") + RefinedSoundexAlgorithm.compute("c").get should equal ("c3") + RefinedSoundexAlgorithm.compute("cc").get should equal ("c3") // d - Algorithm.compute("d").get should equal ("d6") - Algorithm.compute("dd").get should equal ("d6") + RefinedSoundexAlgorithm.compute("d").get should equal ("d6") + RefinedSoundexAlgorithm.compute("dd").get should equal ("d6") // e - Algorithm.compute("e").get should equal ("e0") - Algorithm.compute("ee").get should equal ("e0") + RefinedSoundexAlgorithm.compute("e").get should equal ("e0") + RefinedSoundexAlgorithm.compute("ee").get should equal ("e0") // f - Algorithm.compute("f").get should equal ("f2") - Algorithm.compute("ff").get should equal ("f2") + RefinedSoundexAlgorithm.compute("f").get should equal ("f2") + RefinedSoundexAlgorithm.compute("ff").get should equal ("f2") // g - Algorithm.compute("g").get should equal ("g4") - Algorithm.compute("gg").get should equal ("g4") + RefinedSoundexAlgorithm.compute("g").get should equal ("g4") + RefinedSoundexAlgorithm.compute("gg").get should equal ("g4") // h - Algorithm.compute("h").get should equal ("h0") - Algorithm.compute("hh").get should equal ("h0") + RefinedSoundexAlgorithm.compute("h").get should equal ("h0") + RefinedSoundexAlgorithm.compute("hh").get should equal ("h0") // i - Algorithm.compute("i").get should equal ("i0") - Algorithm.compute("ii").get should equal ("i0") + RefinedSoundexAlgorithm.compute("i").get should equal ("i0") + RefinedSoundexAlgorithm.compute("ii").get should equal ("i0") // j - Algorithm.compute("j").get should equal ("j4") - Algorithm.compute("jj").get should equal ("j4") + RefinedSoundexAlgorithm.compute("j").get should equal ("j4") + RefinedSoundexAlgorithm.compute("jj").get should equal ("j4") // k - Algorithm.compute("k").get should equal ("k3") - Algorithm.compute("kk").get should equal ("k3") + RefinedSoundexAlgorithm.compute("k").get should equal ("k3") + RefinedSoundexAlgorithm.compute("kk").get should equal ("k3") // l - Algorithm.compute("l").get should equal ("l7") - Algorithm.compute("ll").get should equal ("l7") + RefinedSoundexAlgorithm.compute("l").get should equal ("l7") + RefinedSoundexAlgorithm.compute("ll").get should equal ("l7") // m - Algorithm.compute("m").get should equal ("m8") - Algorithm.compute("mm").get should equal ("m8") + RefinedSoundexAlgorithm.compute("m").get should equal ("m8") + RefinedSoundexAlgorithm.compute("mm").get should equal ("m8") // n - Algorithm.compute("n").get should equal ("n8") - Algorithm.compute("nn").get should equal ("n8") + RefinedSoundexAlgorithm.compute("n").get should equal ("n8") + RefinedSoundexAlgorithm.compute("nn").get should equal ("n8") // o - Algorithm.compute("o").get should equal ("o0") - Algorithm.compute("oo").get should equal ("o0") + RefinedSoundexAlgorithm.compute("o").get should equal ("o0") + RefinedSoundexAlgorithm.compute("oo").get should equal ("o0") // p - Algorithm.compute("p").get should equal ("p1") - Algorithm.compute("pp").get should equal ("p1") + RefinedSoundexAlgorithm.compute("p").get should equal ("p1") + RefinedSoundexAlgorithm.compute("pp").get should equal ("p1") // q - Algorithm.compute("q").get should equal ("q5") - Algorithm.compute("qq").get should equal ("q5") + RefinedSoundexAlgorithm.compute("q").get should equal ("q5") + RefinedSoundexAlgorithm.compute("qq").get should equal ("q5") // r - Algorithm.compute("r").get should equal ("r9") - Algorithm.compute("rr").get should equal ("r9") + RefinedSoundexAlgorithm.compute("r").get should equal ("r9") + RefinedSoundexAlgorithm.compute("rr").get should equal ("r9") // s - Algorithm.compute("s").get should equal ("s3") - Algorithm.compute("ss").get should equal ("s3") + RefinedSoundexAlgorithm.compute("s").get should equal ("s3") + RefinedSoundexAlgorithm.compute("ss").get should equal ("s3") // t - Algorithm.compute("t").get should equal ("t6") - Algorithm.compute("tt").get should equal ("t6") + RefinedSoundexAlgorithm.compute("t").get should equal ("t6") + RefinedSoundexAlgorithm.compute("tt").get should equal ("t6") // u - Algorithm.compute("u").get should equal ("u0") - Algorithm.compute("uu").get should equal ("u0") + RefinedSoundexAlgorithm.compute("u").get should equal ("u0") + RefinedSoundexAlgorithm.compute("uu").get should equal ("u0") // v - Algorithm.compute("v").get should equal ("v2") - Algorithm.compute("vv").get should equal ("v2") + RefinedSoundexAlgorithm.compute("v").get should equal ("v2") + RefinedSoundexAlgorithm.compute("vv").get should equal ("v2") // w - Algorithm.compute("w").get should equal ("w0") - Algorithm.compute("ww").get should equal ("w0") + RefinedSoundexAlgorithm.compute("w").get should equal ("w0") + RefinedSoundexAlgorithm.compute("ww").get should equal ("w0") // x - Algorithm.compute("x").get should equal ("x5") - Algorithm.compute("xx").get should equal ("x5") + RefinedSoundexAlgorithm.compute("x").get should equal ("x5") + RefinedSoundexAlgorithm.compute("xx").get should equal ("x5") // y - Algorithm.compute("y").get should equal ("y0") - Algorithm.compute("yy").get should equal ("y0") + RefinedSoundexAlgorithm.compute("y").get should equal ("y0") + RefinedSoundexAlgorithm.compute("yy").get should equal ("y0") // z - Algorithm.compute("z").get should equal ("z5") - Algorithm.compute("zz").get should equal ("z5") + RefinedSoundexAlgorithm.compute("z").get should equal ("z5") + RefinedSoundexAlgorithm.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") + RefinedSoundexAlgorithm.compute("x123456").get should equal ("x5") + RefinedSoundexAlgorithm.compute("a123456").get should equal ("a0") + RefinedSoundexAlgorithm.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.compute("braz").get should equal ("b1905") + RefinedSoundexAlgorithm.compute("broz").get should equal ("b1905") + RefinedSoundexAlgorithm.compute("caren").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("carren").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("coram").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("corran").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("curreen").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("curwen").get should equal ("c30908") + RefinedSoundexAlgorithm.compute("hairs").get should equal ("h093") + RefinedSoundexAlgorithm.compute("hark").get should equal ("h093") + RefinedSoundexAlgorithm.compute("hars").get should equal ("h093") + RefinedSoundexAlgorithm.compute("hayers").get should equal ("h093") + RefinedSoundexAlgorithm.compute("heers").get should equal ("h093") + RefinedSoundexAlgorithm.compute("hiers").get should equal ("h093") + RefinedSoundexAlgorithm.compute("lambard").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lambart").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lambert").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lambird").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lampaert").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lampart").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lamport").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("limbert").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("lombard").get should equal ("l7081096") + RefinedSoundexAlgorithm.compute("nolton").get should equal ("n807608") + RefinedSoundexAlgorithm.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala index cb6a222..57964a5 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/RefinedSoundexMetricSpec.scala @@ -6,45 +6,32 @@ 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) + RefinedSoundexMetric.compare("", "").isDefined should be (false) + RefinedSoundexMetric.compare("abc", "").isDefined should be (false) + RefinedSoundexMetric.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) + RefinedSoundexMetric.compare("123", "123").isDefined should be (false) + RefinedSoundexMetric.compare("123", "").isDefined should be (false) + RefinedSoundexMetric.compare("", "123").isDefined should be (false) } } "phonetically similar arguments" should returns { "Boolean indicating true" in { - Metric.compare("robert", "rupert").get should be (true) + RefinedSoundexMetric.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.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala index 5b7deaa..cfe6ac6 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexAlgorithmSpec.scala @@ -6,169 +6,156 @@ 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) + SoundexAlgorithm.compute("").isDefined should be (false) } } "non-phonetic argument" should returns { "None" in { - Algorithm.compute("123").isDefined should be (false) + SoundexAlgorithm.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") + SoundexAlgorithm.compute("a").get should equal ("a000") + SoundexAlgorithm.compute("aa").get should equal ("a000") // b - Algorithm.compute("b").get should equal ("b000") - Algorithm.compute("bb").get should equal ("b000") + SoundexAlgorithm.compute("b").get should equal ("b000") + SoundexAlgorithm.compute("bb").get should equal ("b000") // c - Algorithm.compute("c").get should equal ("c000") - Algorithm.compute("cc").get should equal ("c000") + SoundexAlgorithm.compute("c").get should equal ("c000") + SoundexAlgorithm.compute("cc").get should equal ("c000") // d - Algorithm.compute("d").get should equal ("d000") - Algorithm.compute("dd").get should equal ("d000") + SoundexAlgorithm.compute("d").get should equal ("d000") + SoundexAlgorithm.compute("dd").get should equal ("d000") // e - Algorithm.compute("e").get should equal ("e000") - Algorithm.compute("ee").get should equal ("e000") + SoundexAlgorithm.compute("e").get should equal ("e000") + SoundexAlgorithm.compute("ee").get should equal ("e000") // f - Algorithm.compute("f").get should equal ("f000") - Algorithm.compute("ff").get should equal ("f000") + SoundexAlgorithm.compute("f").get should equal ("f000") + SoundexAlgorithm.compute("ff").get should equal ("f000") // g - Algorithm.compute("g").get should equal ("g000") - Algorithm.compute("gg").get should equal ("g000") + SoundexAlgorithm.compute("g").get should equal ("g000") + SoundexAlgorithm.compute("gg").get should equal ("g000") // h - Algorithm.compute("h").get should equal ("h000") - Algorithm.compute("hh").get should equal ("h000") + SoundexAlgorithm.compute("h").get should equal ("h000") + SoundexAlgorithm.compute("hh").get should equal ("h000") // i - Algorithm.compute("i").get should equal ("i000") - Algorithm.compute("ii").get should equal ("i000") + SoundexAlgorithm.compute("i").get should equal ("i000") + SoundexAlgorithm.compute("ii").get should equal ("i000") // j - Algorithm.compute("j").get should equal ("j000") - Algorithm.compute("jj").get should equal ("j000") + SoundexAlgorithm.compute("j").get should equal ("j000") + SoundexAlgorithm.compute("jj").get should equal ("j000") // k - Algorithm.compute("k").get should equal ("k000") - Algorithm.compute("kk").get should equal ("k000") + SoundexAlgorithm.compute("k").get should equal ("k000") + SoundexAlgorithm.compute("kk").get should equal ("k000") // l - Algorithm.compute("l").get should equal ("l000") - Algorithm.compute("ll").get should equal ("l000") + SoundexAlgorithm.compute("l").get should equal ("l000") + SoundexAlgorithm.compute("ll").get should equal ("l000") // m - Algorithm.compute("m").get should equal ("m000") - Algorithm.compute("mm").get should equal ("m000") + SoundexAlgorithm.compute("m").get should equal ("m000") + SoundexAlgorithm.compute("mm").get should equal ("m000") // n - Algorithm.compute("n").get should equal ("n000") - Algorithm.compute("nn").get should equal ("n000") + SoundexAlgorithm.compute("n").get should equal ("n000") + SoundexAlgorithm.compute("nn").get should equal ("n000") // o - Algorithm.compute("o").get should equal ("o000") - Algorithm.compute("oo").get should equal ("o000") + SoundexAlgorithm.compute("o").get should equal ("o000") + SoundexAlgorithm.compute("oo").get should equal ("o000") // p - Algorithm.compute("p").get should equal ("p000") - Algorithm.compute("pp").get should equal ("p000") + SoundexAlgorithm.compute("p").get should equal ("p000") + SoundexAlgorithm.compute("pp").get should equal ("p000") // q - Algorithm.compute("q").get should equal ("q000") - Algorithm.compute("qq").get should equal ("q000") + SoundexAlgorithm.compute("q").get should equal ("q000") + SoundexAlgorithm.compute("qq").get should equal ("q000") // r - Algorithm.compute("r").get should equal ("r000") - Algorithm.compute("rr").get should equal ("r000") + SoundexAlgorithm.compute("r").get should equal ("r000") + SoundexAlgorithm.compute("rr").get should equal ("r000") // s - Algorithm.compute("s").get should equal ("s000") - Algorithm.compute("ss").get should equal ("s000") + SoundexAlgorithm.compute("s").get should equal ("s000") + SoundexAlgorithm.compute("ss").get should equal ("s000") // t - Algorithm.compute("t").get should equal ("t000") - Algorithm.compute("tt").get should equal ("t000") + SoundexAlgorithm.compute("t").get should equal ("t000") + SoundexAlgorithm.compute("tt").get should equal ("t000") // u - Algorithm.compute("u").get should equal ("u000") - Algorithm.compute("uu").get should equal ("u000") + SoundexAlgorithm.compute("u").get should equal ("u000") + SoundexAlgorithm.compute("uu").get should equal ("u000") // v - Algorithm.compute("v").get should equal ("v000") - Algorithm.compute("vv").get should equal ("v000") + SoundexAlgorithm.compute("v").get should equal ("v000") + SoundexAlgorithm.compute("vv").get should equal ("v000") // w - Algorithm.compute("w").get should equal ("w000") - Algorithm.compute("ww").get should equal ("w000") + SoundexAlgorithm.compute("w").get should equal ("w000") + SoundexAlgorithm.compute("ww").get should equal ("w000") // x - Algorithm.compute("x").get should equal ("x000") - Algorithm.compute("xx").get should equal ("x000") + SoundexAlgorithm.compute("x").get should equal ("x000") + SoundexAlgorithm.compute("xx").get should equal ("x000") // y - Algorithm.compute("y").get should equal ("y000") - Algorithm.compute("yy").get should equal ("y000") + SoundexAlgorithm.compute("y").get should equal ("y000") + SoundexAlgorithm.compute("yy").get should equal ("y000") // z - Algorithm.compute("z").get should equal ("z000") - Algorithm.compute("zz").get should equal ("z000") + SoundexAlgorithm.compute("z").get should equal ("z000") + SoundexAlgorithm.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") + SoundexAlgorithm.compute("x123456").get should equal ("x000") + SoundexAlgorithm.compute("a123456").get should equal ("a000") + SoundexAlgorithm.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.compute("abc").get should equal ("a120") + SoundexAlgorithm.compute("xyz").get should equal ("x200") + SoundexAlgorithm.compute("robert").get should equal ("r163") + SoundexAlgorithm.compute("rupert").get should equal ("r163") + SoundexAlgorithm.compute("rubin").get should equal ("r150") + SoundexAlgorithm.compute("ashcraft").get should equal ("a261") + SoundexAlgorithm.compute("tymczak").get should equal ("t522") + SoundexAlgorithm.compute("pfister").get should equal ("p236") + SoundexAlgorithm.compute("euler").get should equal ("e460") + SoundexAlgorithm.compute("gauss").get should equal ("g200") + SoundexAlgorithm.compute("hilbert").get should equal ("h416") + SoundexAlgorithm.compute("knuth").get should equal ("k530") + SoundexAlgorithm.compute("lloyd").get should equal ("l300") + SoundexAlgorithm.compute("lukasiewicz").get should equal ("l222") + SoundexAlgorithm.compute("ashcroft").get should equal ("a261") + SoundexAlgorithm.compute("tymczak").get should equal ("t522") + SoundexAlgorithm.compute("pfister").get should equal ("p236") + SoundexAlgorithm.compute("ellery").get should equal ("e460") + SoundexAlgorithm.compute("ghosh").get should equal ("g200") + SoundexAlgorithm.compute("heilbronn").get should equal ("h416") + SoundexAlgorithm.compute("kant").get should equal ("k530") + SoundexAlgorithm.compute("ladd").get should equal ("l300") + SoundexAlgorithm.compute("lissajous").get should equal ("l222") + SoundexAlgorithm.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/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala index 9fc47d8..6d4873a 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/phonetic/SoundexMetricSpec.scala @@ -6,45 +6,32 @@ 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) + SoundexMetric.compare("", "").isDefined should be (false) + SoundexMetric.compare("abc", "").isDefined should be (false) + SoundexMetric.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) + SoundexMetric.compare("123", "123").isDefined should be (false) + SoundexMetric.compare("123", "").isDefined should be (false) + SoundexMetric.compare("", "123").isDefined should be (false) } } "phonetically similar arguments" should returns { "Boolean indicating true" in { - Metric.compare("robert", "rupert").get should be (true) + SoundexMetric.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.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala index 5ddfc06..6611e27 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/DiceSorensenMetricSpec.scala @@ -6,70 +6,57 @@ 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) + DiceSorensenMetric(1).compare("", "").isDefined should be (false) + DiceSorensenMetric(1).compare("abc", "").isDefined should be (false) + DiceSorensenMetric(1).compare("", "xyz").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) + DiceSorensenMetric(1).compare("abc", "abc").get should be (1) + DiceSorensenMetric(2).compare("abc", "abc").get should be (1) + DiceSorensenMetric(2).compare("abc", "abc").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) + DiceSorensenMetric(1).compare("abc", "xyz").get should be (0) + DiceSorensenMetric(2).compare("abc", "xyz").get should be (0) + DiceSorensenMetric(3).compare("abc", "xyz").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) + DiceSorensenMetric(2).compare("n", "naght").isDefined should be (false) + DiceSorensenMetric(2).compare("night", "n").isDefined should be (false) + DiceSorensenMetric(3).compare("ni", "naght").isDefined should be (false) + DiceSorensenMetric(3).compare("night", "na").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) + DiceSorensenMetric(1).compare("night", "nacht").get should be (0.6) + DiceSorensenMetric(1).compare("night", "naght").get should be (0.8) + DiceSorensenMetric(1).compare("context", "contact").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) + DiceSorensenMetric(2).compare("night", "nacht").get should be (0.25) + DiceSorensenMetric(2).compare("night", "naght").get should be (0.5) + DiceSorensenMetric(2).compare("context", "contact").get should be (0.5) + DiceSorensenMetric(2).compare("contextcontext", "contact").get should be (0.3157894736842105) + DiceSorensenMetric(2).compare("context", "contactcontact").get should be (0.3157894736842105) + DiceSorensenMetric(2).compare("ht", "nacht").get should be (0.4) + DiceSorensenMetric(2).compare("xp", "nacht").get should be (0) + DiceSorensenMetric(2).compare("ht", "hththt").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(3).compare("night", "nacht").get should be (0) + DiceSorensenMetric(3).compare("night", "naght").get should be (0.3333333333333333) + DiceSorensenMetric(3).compare("context", "contact").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/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala index c69d860..c26996a 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/HammingMetricSpec.scala @@ -6,47 +6,34 @@ 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) + HammingMetric.compare("", "").isDefined should be (false) + HammingMetric.compare("abc", "").isDefined should be (false) + HammingMetric.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) + HammingMetric.compare("abc", "abc").get should be (0) + HammingMetric.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) + HammingMetric.compare("abc", "xyz").get should be (3) + HammingMetric.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.compare("toned", "roses").get should be (3) + HammingMetric.compare("1011101", "1001001").get should be (2) + HammingMetric.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala index 17bc3ef..06b8928 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaccardMetricSpec.scala @@ -6,72 +6,57 @@ 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) + JaccardMetric(1).compare("", "").isDefined should be (false) + JaccardMetric(1).compare("abc", "").isDefined should be (false) + JaccardMetric(1).compare("", "xyz").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) + JaccardMetric(1).compare("abc", "abc").get should be (1) + JaccardMetric(2).compare("abc", "abc").get should be (1) + JaccardMetric(3).compare("abc", "abc").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) + JaccardMetric(1).compare("abc", "xyz").get should be (0) + JaccardMetric(2).compare("abc", "xyz").get should be (0) + JaccardMetric(3).compare("abc", "xyz").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) + JaccardMetric(2).compare("n", "naght").isDefined should be (false) + JaccardMetric(2).compare("night", "n").isDefined should be (false) + JaccardMetric(3).compare("ni", "naght").isDefined should be (false) + JaccardMetric(3).compare("night", "na").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(1).compare("night", "nacht").get should be (0.42857142857142855) + JaccardMetric(1).compare("night", "naght").get should be (0.6666666666666666) + JaccardMetric(1).compare("context", "contact").get should be (0.5555555555555556) + + JaccardMetric(2).compare("night", "nacht").get should be (0.14285714285714285) + JaccardMetric(2).compare("night", "naght").get should be (0.3333333333333333) + JaccardMetric(2).compare("context", "contact").get should be (0.3333333333333333) + JaccardMetric(2).compare("contextcontext", "contact").get should be (0.1875) + JaccardMetric(2).compare("context", "contactcontact").get should be (0.1875) + JaccardMetric(2).compare("ht", "nacht").get should be (0.25) + JaccardMetric(2).compare("xp", "nacht").get should be (0) + JaccardMetric(2).compare("ht", "hththt").get should be (0.2) + + JaccardMetric(3).compare("night", "nacht").get should be (0) + JaccardMetric(3).compare("night", "naght").get should be (0.2) + JaccardMetric(3).compare("context", "contact").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/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala index 00f4daf..d5037c5 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroMetricSpec.scala @@ -6,61 +6,48 @@ 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) + JaroMetric.compare("", "").isDefined should be (false) + JaroMetric.compare("abc", "").isDefined should be (false) + JaroMetric.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) + JaroMetric.compare("a", "a").get should be (1) + JaroMetric.compare("abc", "abc").get should be (1) + JaroMetric.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) + JaroMetric.compare("abc", "xyz").get should be (0) + JaroMetric.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) + JaroMetric.compare("aa", "a").get should be (0.8333333333333334) + JaroMetric.compare("a", "aa").get should be (0.8333333333333334) + JaroMetric.compare("veryveryverylong", "v").get should be (0.6875) + JaroMetric.compare("v", "veryveryverylong").get should be (0.6875) + JaroMetric.compare("martha", "marhta").get should be (0.9444444444444445) + JaroMetric.compare("dwayne", "duane").get should be (0.8222222222222223) + JaroMetric.compare("dixon", "dicksonx").get should be (0.7666666666666666) + JaroMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334) + JaroMetric.compare("jones", "johnson").get should be (0.7904761904761904) + JaroMetric.compare("henka", "henkan").get should be (0.9444444444444445) + JaroMetric.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.compare("zac ephron", "zac efron").get should be > + JaroMetric.compare("zac ephron", "kai ephron").get + JaroMetric.compare("brittney spears", "britney spears").get should be > + JaroMetric.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala index 06421a8..14f7cbb 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/JaroWinklerMetricSpec.scala @@ -6,61 +6,48 @@ 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) + JaroWinklerMetric.compare("", "").isDefined should be (false) + JaroWinklerMetric.compare("abc", "").isDefined should be (false) + JaroWinklerMetric.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) + JaroWinklerMetric.compare("a", "a").get should be (1) + JaroWinklerMetric.compare("abc", "abc").get should be (1) + JaroWinklerMetric.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) + JaroWinklerMetric.compare("abc", "xyz").get should be (0) + JaroWinklerMetric.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) + JaroWinklerMetric.compare("aa", "a").get should be (0.8500000000000001) + JaroWinklerMetric.compare("a", "aa").get should be (0.8500000000000001) + JaroWinklerMetric.compare("veryveryverylong", "v").get should be (0.71875) + JaroWinklerMetric.compare("v", "veryveryverylong").get should be (0.71875) + JaroWinklerMetric.compare("martha", "marhta").get should be (0.9611111111111111) + JaroWinklerMetric.compare("dwayne", "duane").get should be (0.8400000000000001) + JaroWinklerMetric.compare("dixon", "dicksonx").get should be (0.8133333333333332) + JaroWinklerMetric.compare("abcvwxyz", "cabvwxyz").get should be (0.9583333333333334) + JaroWinklerMetric.compare("jones", "johnson").get should be (0.8323809523809523) + JaroWinklerMetric.compare("henka", "henkan").get should be (0.9666666666666667) + JaroWinklerMetric.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.compare("zac ephron", "zac efron").get should be > + JaroWinklerMetric.compare("zac ephron", "kai ephron").get + JaroWinklerMetric.compare("brittney spears", "britney spears").get should be > + JaroWinklerMetric.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala index 51de2ca..8e8bf11 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/LevenshteinMetricSpec.scala @@ -6,60 +6,47 @@ 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) + LevenshteinMetric.compare("", "").isDefined should be (false) + LevenshteinMetric.compare("abc", "").isDefined should be (false) + LevenshteinMetric.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) + LevenshteinMetric.compare("abc", "abc").get should be (0) + LevenshteinMetric.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) + LevenshteinMetric.compare("abc", "xyz").get should be (3) + LevenshteinMetric.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.compare("abc", "a").get should be (2) + LevenshteinMetric.compare("a", "abc").get should be (2) + LevenshteinMetric.compare("abc", "c").get should be (2) + LevenshteinMetric.compare("c", "abc").get should be (2) + LevenshteinMetric.compare("sitting", "kitten").get should be (3) + LevenshteinMetric.compare("kitten", "sitting").get should be (3) + LevenshteinMetric.compare("cake", "drake").get should be (2) + LevenshteinMetric.compare("drake", "cake").get should be (2) + LevenshteinMetric.compare("saturday", "sunday").get should be (3) + LevenshteinMetric.compare("sunday", "saturday").get should be (3) + LevenshteinMetric.compare("book", "back").get should be (2) + LevenshteinMetric.compare("dog", "fog").get should be (1) + LevenshteinMetric.compare("foq", "fog").get should be (1) + LevenshteinMetric.compare("fvg", "fog").get should be (1) + LevenshteinMetric.compare("encyclopedia", "encyclopediaz").get should be (1) + LevenshteinMetric.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala index 39d97e5..6d9749e 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/NGramMetricSpec.scala @@ -6,70 +6,57 @@ 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) + NGramMetric(1).compare("", "").isDefined should be (false) + NGramMetric(1).compare("abc", "").isDefined should be (false) + NGramMetric(1).compare("", "xyz").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) + NGramMetric(1).compare("abc", "abc").get should be (1) + NGramMetric(2).compare("abc", "abc").get should be (1) + NGramMetric(3).compare("abc", "abc").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) + NGramMetric(1).compare("abc", "xyz").get should be (0) + NGramMetric(2).compare("abc", "xyz").get should be (0) + NGramMetric(3).compare("abc", "xyz").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) + NGramMetric(2).compare("n", "naght").isDefined should be (false) + NGramMetric(2).compare("night", "n").isDefined should be (false) + NGramMetric(3).compare("ni", "naght").isDefined should be (false) + NGramMetric(3).compare("night", "na").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) + NGramMetric(1).compare("night", "nacht").get should be (0.6) + NGramMetric(1).compare("night", "naght").get should be (0.8) + NGramMetric(1).compare("context", "contact").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) + NGramMetric(2).compare("night", "nacht").get should be (0.25) + NGramMetric(2).compare("night", "naght").get should be (0.5) + NGramMetric(2).compare("context", "contact").get should be (0.5) + NGramMetric(2).compare("contextcontext", "contact").get should be (0.23076923076923078) + NGramMetric(2).compare("context", "contactcontact").get should be (0.23076923076923078) + NGramMetric(2).compare("ht", "nacht").get should be (0.25) + NGramMetric(2).compare("xp", "nacht").get should be (0) + NGramMetric(2).compare("ht", "hththt").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(3).compare("night", "nacht").get should be (0) + NGramMetric(3).compare("night", "naght").get should be (0.3333333333333333) + NGramMetric(3).compare("context", "contact").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/core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala index 32c9650..20d1b2e 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/OverlapMetricSpec.scala @@ -6,72 +6,59 @@ 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) + OverlapMetric(1).compare("", "").isDefined should be (false) + OverlapMetric(1).compare("abc", "").isDefined should be (false) + OverlapMetric(1).compare("", "xyz").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) + OverlapMetric(1).compare("abc", "abc").get should be (1) + OverlapMetric(2).compare("abc", "abc").get should be (1) + OverlapMetric(3).compare("abc", "abc").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) + OverlapMetric(1).compare("abc", "xyz").get should be (0) + OverlapMetric(2).compare("abc", "xyz").get should be (0) + OverlapMetric(3).compare("abc", "xyz").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) + OverlapMetric(2).compare("n", "naght").isDefined should be (false) + OverlapMetric(2).compare("night", "n").isDefined should be (false) + OverlapMetric(3).compare("ni", "naght").isDefined should be (false) + OverlapMetric(3).compare("night", "na").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) + OverlapMetric(1).compare("bob", "bobman").get should be (1) + OverlapMetric(1).compare("bob", "manbobman").get should be (1) + OverlapMetric(1).compare("night", "nacht").get should be (0.6) + OverlapMetric(1).compare("night", "naght").get should be (0.8) + OverlapMetric(1).compare("context", "contact").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) + OverlapMetric(2).compare("night", "nacht").get should be (0.25) + OverlapMetric(2).compare("night", "naght").get should be (0.5) + OverlapMetric(2).compare("context", "contact").get should be (0.5) + OverlapMetric(2).compare("contextcontext", "contact").get should be (0.5) + OverlapMetric(2).compare("context", "contactcontact").get should be (0.5) + OverlapMetric(2).compare("ht", "nacht").get should be (1) + OverlapMetric(2).compare("xp", "nacht").get should be (0) + OverlapMetric(2).compare("ht", "hththt").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(3).compare("night", "nacht").get should be (0) + OverlapMetric(3).compare("night", "naght").get should be (0.3333333333333333) + OverlapMetric(3).compare("context", "contact").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/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala index 638536f..e1ff9cf 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/RatcliffObershelpMetricSpec.scala @@ -6,51 +6,37 @@ 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) + RatcliffObershelpMetric.compare("", "").isDefined should be (false) + RatcliffObershelpMetric.compare("abc", "").isDefined should be (false) + RatcliffObershelpMetric.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) + RatcliffObershelpMetric.compare("abc", "abc").get should be (1) + RatcliffObershelpMetric.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) + RatcliffObershelpMetric.compare("abc", "xyz").get should be (0) + RatcliffObershelpMetric.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.compare("aleksander", "alexandre").get should be (0.7368421052631579) + RatcliffObershelpMetric.compare("alexandre", "aleksander").get should be (0.7368421052631579) + RatcliffObershelpMetric.compare("pennsylvania", "pencilvaneya").get should be (0.6666666666666666) + RatcliffObershelpMetric.compare("pencilvaneya", "pennsylvania").get should be (0.6666666666666666) + RatcliffObershelpMetric.compare("abcefglmn", "abefglmo").get should be (0.8235294117647058) + RatcliffObershelpMetric.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/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala index 9c46c89..bcd17ec 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/similarity/WeightedLevenshteinMetricSpec.scala @@ -6,59 +6,45 @@ 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) + WeightedLevenshteinMetric(10, 0.1, 1).compare("", "").isDefined should be (false) + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "").isDefined should be (false) + WeightedLevenshteinMetric(10, 0.1, 1).compare("", "xyz").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) + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "abc").get should be (0) + WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "123").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) + WeightedLevenshteinMetric(10, 0.1, 1).compare("abc", "xyz").get should be (3) + WeightedLevenshteinMetric(10, 0.1, 1).compare("123", "456").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(10, 0.1, 1).compare("az", "z").get should be (10) + WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "az").get should be (0.1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("a", "z").get should be (1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("z", "a").get should be (1) + WeightedLevenshteinMetric(10, 0.1, 1).compare("ab", "yz").get should be (2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("yz", "ab").get should be (2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("0", "0123456789").get should be (0.9) + WeightedLevenshteinMetric(10, 0.1, 1).compare("0123456789", "0").get should be (90) + WeightedLevenshteinMetric(10, 0.1, 1).compare("book", "back").get should be (2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("back", "book").get should be (2) + WeightedLevenshteinMetric(10, 0.1, 1).compare("hosp", "hospital").get should be (0.4) + WeightedLevenshteinMetric(10, 0.1, 1).compare("hospital", "hosp").get should be (40) + WeightedLevenshteinMetric(10, 0.1, 1).compare("clmbs blvd", "columbus boulevard").get should be (0.8) + WeightedLevenshteinMetric(10, 0.1, 1).compare("columbus boulevard", "clmbs blvd").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/core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala b/core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala index 56fdc13..1598a93 100755 --- a/core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala +++ b/core/source/test/scala/com/rockymadden/stringmetric/tokenization/NGramTokenizerSpec.scala @@ -5,65 +5,40 @@ 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] - } +final class NGramTokenizerSpec extends ScalaTest { "NGramTokenizer" should provide { + "tokenize method" when passed { + "empty argument" should returns { + "None" in { + NGramTokenizer(1).tokenize("").isDefined should be (false) } - "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" - ) - ) - } + } + "invalid n argument" should returns { + "None" in { + NGramTokenizer(0).tokenize("").isDefined should be (false) + NGramTokenizer(-1).tokenize("").isDefined should be (false) } } - } - "NGramTokenizer companion object" should provide { - "pass-through tokenize method" should returns { - "same value as class" in { - NGramTokenizer.tokenize("abcdefghijklmnopqrstuvwxyz")(1).get should equal ( + "valid argument" should returns { + "Array[String]" in { + NGramTokenizer(1).tokenize("abcdefghijklmnopqrstuvwxyz").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" ) ) + NGramTokenizer(2).tokenize("abcdefghijklmnopqrstuvwxyz").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" + ) + ) + NGramTokenizer(3).tokenize("abcdefghijklmnopqrstuvwxyz").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" + ) + ) } } } -} - -object NGramTokenizerSpec { - private final val Tokenizer = NGramTokenizer() -} +}} |