diff options
author | Rocky Madden <git@rockymadden.com> | 2013-03-07 23:01:22 -0700 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-03-07 23:01:22 -0700 |
commit | 7c7170baaa0c5eff0b85592c4ad2622d3a24eb42 (patch) | |
tree | 04eb5e2e04981a1fa002259ea01bdcc39b573014 /core/source | |
parent | d3ee1e3fa282de1a6696ca54a3bb4c89c10a28ce (diff) | |
download | stringmetric-7c7170baaa0c5eff0b85592c4ad2622d3a24eb42.tar.gz stringmetric-7c7170baaa0c5eff0b85592c4ad2622d3a24eb42.tar.bz2 stringmetric-7c7170baaa0c5eff0b85592c4ad2622d3a24eb42.zip |
Added types and object references to convenience objects.
Diffstat (limited to 'core/source')
6 files changed, 79 insertions, 11 deletions
diff --git a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala index 33f9e80..17c46d1 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringAlgorithm.scala @@ -1,12 +1,12 @@ package com.rockymadden.stringmetric -import com.rockymadden.stringmetric.similarity.NGramAlgorithm - trait ConfigurableStringAlgorithm[R, O] extends ConfigurableAlgorithm[String, R, O] { def compute(charArray: Array[Char])(implicit o: O): Option[Array[_]] } object ConfigurableStringAlgorithm { + type NGramAlgorithm = com.rockymadden.stringmetric.similarity.NGramAlgorithm + val NGramAlgorithm = com.rockymadden.stringmetric.similarity.NGramAlgorithm lazy val nGram = NGramAlgorithm() def computeWithNGram(charArray: Array[Char])(n: Int): Option[Array[Array[Char]]] = nGram.compute(charArray)(n) diff --git a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala index ae04a9f..9afc102 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/ConfigurableStringMetric.scala @@ -1,14 +1,20 @@ package com.rockymadden.stringmetric -import com.rockymadden.stringmetric.similarity.{ DiceSorensenMetric, NGramMetric, WeightedLevenshteinMetric } - trait ConfigurableStringMetric[R, O] extends ConfigurableMetric[String, R, O] { def compare(charArray1: Array[Char], charArray2: Array[Char])(implicit o: O): Option[R] } object ConfigurableStringMetric { + type DiceSorensenMetric = com.rockymadden.stringmetric.similarity.DiceSorensenMetric + val DiceSorensenMetric = com.rockymadden.stringmetric.similarity.DiceSorensenMetric lazy val diceSorensen = DiceSorensenMetric() + + type NGramMetric = com.rockymadden.stringmetric.similarity.NGramMetric + val NGramMetric = com.rockymadden.stringmetric.similarity.NGramMetric lazy val nGram = NGramMetric() + + type WeightedLevenshteinMetric = com.rockymadden.stringmetric.similarity.WeightedLevenshteinMetric + val WeightedLevenshteinMetric = com.rockymadden.stringmetric.similarity.WeightedLevenshteinMetric lazy val weightedLevenshtein = WeightedLevenshteinMetric() def compareWithDiceSorensen(charArray1: Array[Char], charArray2: Array[Char])(n: Int): Option[Double] = diff --git a/core/source/core/scala/com/rockymadden/stringmetric/Memoizable.scala b/core/source/core/scala/com/rockymadden/stringmetric/Memoizable.scala new file mode 100755 index 0000000..8983ad5 --- /dev/null +++ b/core/source/core/scala/com/rockymadden/stringmetric/Memoizable.scala @@ -0,0 +1,5 @@ +package com.rockymadden.stringmetric + +trait Memoizable { + def memo() +} diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala index 96edd78..1cd43f1 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringAlgorithm.scala @@ -1,16 +1,28 @@ package com.rockymadden.stringmetric -import com.rockymadden.stringmetric.phonetic._ - trait StringAlgorithm[R] extends Algorithm[String, R] { def compute(charArray: Array[Char]): Option[Array[_]] } object StringAlgorithm { + type MetaphoneAlgorithm = com.rockymadden.stringmetric.phonetic.MetaphoneAlgorithm + val MetaphoneAlgorithm = com.rockymadden.stringmetric.phonetic.MetaphoneAlgorithm lazy val metaphone = MetaphoneAlgorithm() + + type NysiisAlgorithm = com.rockymadden.stringmetric.phonetic.NysiisAlgorithm + val NysiisAlgorithm = com.rockymadden.stringmetric.phonetic.NysiisAlgorithm lazy val nysiis = NysiisAlgorithm() + + type RefinedNysiisAlgorithm = com.rockymadden.stringmetric.phonetic.RefinedNysiisAlgorithm + val RefinedNysiisAlgorithm = com.rockymadden.stringmetric.phonetic.RefinedNysiisAlgorithm lazy val refinedNysiis = RefinedNysiisAlgorithm() + + type RefinedSoundexAlgorithm = com.rockymadden.stringmetric.phonetic.RefinedSoundexAlgorithm + val RefinedSoundexAlgorithm = com.rockymadden.stringmetric.phonetic.RefinedSoundexAlgorithm lazy val refinedSoundex = RefinedSoundexAlgorithm() + + type SoundexAlgorithm = com.rockymadden.stringmetric.phonetic.SoundexAlgorithm + val SoundexAlgorithm = com.rockymadden.stringmetric.phonetic.SoundexAlgorithm lazy val soundex = SoundexAlgorithm() def computeWithMetaphone(charArray: Array[Char]): Option[Array[Char]] = metaphone.compute(charArray) diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala index c3fa3ad..d795f3f 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringFilter.scala @@ -1,23 +1,45 @@ package com.rockymadden.stringmetric -import com.rockymadden.stringmetric.filter._ +import com.rockymadden.stringmetric.filter.StringFilterDelegate trait StringFilter extends Filter[String] with StringFilterable { override def filter(charArray: Array[Char]): Array[Char] = charArray } object StringFilter { + type AsciiControlStringFilter = com.rockymadden.stringmetric.filter.AsciiControlStringFilter lazy val asciiControl = new StringFilterDelegate with AsciiControlStringFilter + + type AsciiControlOnlyStringFilter = com.rockymadden.stringmetric.filter.AsciiControlOnlyStringFilter lazy val asciiControlOnly = new StringFilterDelegate with AsciiControlOnlyStringFilter + + type AsciiLetterCaseStringFilter = com.rockymadden.stringmetric.filter.AsciiLetterCaseStringFilter lazy val asciiLetterCase = new StringFilterDelegate with AsciiLetterCaseStringFilter + + type AsciiLetterNumberStringFilter = com.rockymadden.stringmetric.filter.AsciiLetterNumberStringFilter lazy val asciiLetterNumber = new StringFilterDelegate with AsciiLetterNumberStringFilter + + type AsciiLetterNumberOnlyStringFilter = com.rockymadden.stringmetric.filter.AsciiLetterNumberOnlyStringFilter lazy val asciiLetterNumberOnly = new StringFilterDelegate with AsciiLetterNumberOnlyStringFilter + + type AsciiLetterStringFilter = com.rockymadden.stringmetric.filter.AsciiLetterStringFilter lazy val asciiLetter = new StringFilterDelegate with AsciiLetterStringFilter + + type AsciiLetterOnlyStringFilter = com.rockymadden.stringmetric.filter.AsciiLetterOnlyStringFilter lazy val asciiLetterOnly = new StringFilterDelegate with AsciiLetterOnlyStringFilter + + type AsciiNumberStringFilter = com.rockymadden.stringmetric.filter.AsciiNumberStringFilter lazy val asciiNumber = new StringFilterDelegate with AsciiNumberStringFilter + + type AsciiNumberOnlyStringFilter = com.rockymadden.stringmetric.filter.AsciiNumberOnlyStringFilter lazy val asciiNumberOnly = new StringFilterDelegate with AsciiNumberOnlyStringFilter + + type AsciiSpaceStringFilter = com.rockymadden.stringmetric.filter.AsciiSpaceStringFilter lazy val asciiSpace = new StringFilterDelegate with AsciiSpaceStringFilter + + type AsciiSymbolStringFilter = com.rockymadden.stringmetric.filter.AsciiSymbolStringFilter lazy val asciiSymbol = new StringFilterDelegate with AsciiSymbolStringFilter + + type AsciiSymbolOnlyStringFilter = com.rockymadden.stringmetric.filter.AsciiSymbolOnlyStringFilter lazy val asciiSymbolOnly = new StringFilterDelegate with AsciiSymbolOnlyStringFilter - lazy val delegate = new StringFilterDelegate } diff --git a/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala b/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala index f9b072b..4e90f8c 100755 --- a/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala +++ b/core/source/core/scala/com/rockymadden/stringmetric/StringMetric.scala @@ -1,21 +1,44 @@ package com.rockymadden.stringmetric -import com.rockymadden.stringmetric.phonetic._ -import com.rockymadden.stringmetric.similarity._ - trait StringMetric[R] extends Metric[String, R] { def compare(charArray1: Array[Char], charArray2: Array[Char]): Option[R] } object StringMetric { + type HammingMetric = com.rockymadden.stringmetric.similarity.HammingMetric + val HammingMetric = com.rockymadden.stringmetric.similarity.HammingMetric lazy val hamming = HammingMetric() + + type JaroMetric = com.rockymadden.stringmetric.similarity.JaroMetric + val JaroMetric = com.rockymadden.stringmetric.similarity.JaroMetric lazy val jaro = JaroMetric() + + type JaroWinklerMetric = com.rockymadden.stringmetric.similarity.JaroWinklerMetric + val JaroWinklerMetric = com.rockymadden.stringmetric.similarity.JaroWinklerMetric lazy val jaroWinkler = JaroWinklerMetric() + + type LevenshteinMetric = com.rockymadden.stringmetric.similarity.LevenshteinMetric + val LevenshteinMetric = com.rockymadden.stringmetric.similarity.LevenshteinMetric lazy val levenshtein = LevenshteinMetric() + + type MetaphoneMetric = com.rockymadden.stringmetric.phonetic.MetaphoneMetric + val MetaphoneMetric = com.rockymadden.stringmetric.phonetic.MetaphoneMetric lazy val metaphone = MetaphoneMetric() + + type NysiisMetric = com.rockymadden.stringmetric.phonetic.NysiisMetric + val NysiisMetric = com.rockymadden.stringmetric.phonetic.NysiisMetric lazy val nysiis = NysiisMetric() + + type RefinedNysiisMetric = com.rockymadden.stringmetric.phonetic.RefinedNysiisMetric + val RefinedNysiisMetric = com.rockymadden.stringmetric.phonetic.RefinedNysiisMetric lazy val refinedNysiis = RefinedNysiisMetric() + + type RefinedSoundexMetric = com.rockymadden.stringmetric.phonetic.RefinedSoundexMetric + val RefinedSoundexMetric = com.rockymadden.stringmetric.phonetic.RefinedSoundexMetric lazy val refinedSoundex = RefinedSoundexMetric() + + type SoundexMetric = com.rockymadden.stringmetric.phonetic.SoundexMetric + val SoundexMetric = com.rockymadden.stringmetric.phonetic.SoundexMetric lazy val soundex = SoundexMetric() def compareWithHamming(charArray1: Array[Char], charArray2: Array[Char]): Option[Int] = |