diff options
author | Rocky Madden <git@rockymadden.com> | 2012-10-29 13:31:47 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2012-10-29 13:31:47 -0600 |
commit | 400973bb472918b6046cd7fc1ef65f040225d1b3 (patch) | |
tree | d02ca9b6eb539fd5475b5c82c3e6030b10fac0f6 /core/source/test | |
parent | 26d85c948eb5359e62f9ad54469a3730fb0499f5 (diff) | |
download | stringmetric-400973bb472918b6046cd7fc1ef65f040225d1b3.tar.gz stringmetric-400973bb472918b6046cd7fc1ef65f040225d1b3.tar.bz2 stringmetric-400973bb472918b6046cd7fc1ef65f040225d1b3.zip |
Created refined soundex algorithm, metric, command, and specs.
Diffstat (limited to 'core/source/test')
3 files changed, 95 insertions, 1 deletions
diff --git a/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetricSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetricSpec.scala new file mode 100755 index 0000000..9524835 --- /dev/null +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexMetricSpec.scala @@ -0,0 +1,37 @@ +package org.hashtree.stringmetric.phonetic + +import org.hashtree.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class RefinedSoundexMetricSpec extends ScalaTest { + "RefinedSoundexMetric" should provide { + "compare method" when passed { + "empty arguments" should returns { + "None" in { + 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 { + 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 { + RefinedSoundexMetric.compare("robert", "rupert").get should be (true) + } + } + "phonetically dissimilar arguments" should returns { + "Boolean indicating false" in { + RefinedSoundexMetric.compare("robert", "rubin").get should be (false) + } + } + } + } +}
\ No newline at end of file diff --git a/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexSpec.scala new file mode 100755 index 0000000..1531eb0 --- /dev/null +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/RefinedSoundexSpec.scala @@ -0,0 +1,54 @@ +package org.hashtree.stringmetric.phonetic + +import org.hashtree.stringmetric.ScalaTest +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +final class RefinedSoundexSpec extends ScalaTest { + "RefinedSoundex" should provide { + "compute method" when passed { + "empty argument" should returns { + "None" in { + RefinedSoundex.compute("").isDefined should be (false) + } + } + "non-phonetic argument" should returns { + "None" in { + RefinedSoundex.compute("123").isDefined should be (false) + } + } + "phonetic argument" should returns { + "Some" in { + RefinedSoundex.compute("x123").get should equal ("x5") + + RefinedSoundex.compute("braz").get should equal ("b1905") + RefinedSoundex.compute("broz").get should equal ("b1905") + RefinedSoundex.compute("caren").get should equal ("c30908") + RefinedSoundex.compute("carren").get should equal ("c30908") + RefinedSoundex.compute("coram").get should equal ("c30908") + RefinedSoundex.compute("corran").get should equal ("c30908") + RefinedSoundex.compute("curreen").get should equal ("c30908") + RefinedSoundex.compute("curwen").get should equal ("c30908") + RefinedSoundex.compute("hairs").get should equal ("h093") + RefinedSoundex.compute("hark").get should equal ("h093") + RefinedSoundex.compute("hars").get should equal ("h093") + RefinedSoundex.compute("hayers").get should equal ("h093") + RefinedSoundex.compute("heers").get should equal ("h093") + RefinedSoundex.compute("hiers").get should equal ("h093") + RefinedSoundex.compute("lambard").get should equal ("l7081096") + RefinedSoundex.compute("lambart").get should equal ("l7081096") + RefinedSoundex.compute("lambert").get should equal ("l7081096") + RefinedSoundex.compute("lambird").get should equal ("l7081096") + RefinedSoundex.compute("lampaert").get should equal ("l7081096") + RefinedSoundex.compute("lampart").get should equal ("l7081096") + RefinedSoundex.compute("lamport").get should equal ("l7081096") + RefinedSoundex.compute("limbert").get should equal ("l7081096") + RefinedSoundex.compute("lombard").get should equal ("l7081096") + RefinedSoundex.compute("nolton").get should equal ("n807608") + RefinedSoundex.compute("noulton").get should equal ("n807608") + } + } + } + } +}
\ No newline at end of file diff --git a/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexSpec.scala b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexSpec.scala index dbefc51..9f18bc9 100755 --- a/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexSpec.scala +++ b/core/source/test/scala/org/hashtree/stringmetric/phonetic/SoundexSpec.scala @@ -20,8 +20,11 @@ final class SoundexSpec extends ScalaTest { } "phonetic argument" should returns { "Some" in { + Soundex.compute("x123").get should equal ("x000") + Soundex.compute("abc").get should equal ("a120") Soundex.compute("xyz").get should equal ("x200") + Soundex.compute("robert").get should equal ("r163") Soundex.compute("rupert").get should equal ("r163") Soundex.compute("rubin").get should equal ("r150") @@ -43,7 +46,7 @@ final class SoundexSpec extends ScalaTest { Soundex.compute("kant").get should equal ("k530") Soundex.compute("ladd").get should equal ("l300") Soundex.compute("lissajous").get should equal ("l222") - Soundex.compute("x123").get should equal ("x000") + Soundex.compute("fusedale").get should equal ("f234") } } } |