diff options
author | Rocky Madden <git@rockymadden.com> | 2013-05-20 16:30:52 -0600 |
---|---|---|
committer | Rocky Madden <git@rockymadden.com> | 2013-05-20 16:30:52 -0600 |
commit | c0de09e838282fa708125570971bdca15f905d06 (patch) | |
tree | 217c55b47b7baf3d6f8e134ba86bd59571550182 /cli | |
parent | 6c8a9f1ca60822ca2ee1839bca2cd00afea7037f (diff) | |
download | stringmetric-c0de09e838282fa708125570971bdca15f905d06.tar.gz stringmetric-c0de09e838282fa708125570971bdca15f905d06.tar.bz2 stringmetric-c0de09e838282fa708125570971bdca15f905d06.zip |
Changed subproject folder naming. Updated Scala to 2.10.1.
Diffstat (limited to 'cli')
48 files changed, 0 insertions, 2309 deletions
diff --git a/cli/build.gradle b/cli/build.gradle deleted file mode 100755 index c0d1b89..0000000 --- a/cli/build.gradle +++ /dev/null @@ -1,167 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'signing' - -def isMavenDeployable = hasProperty('mavenRepositoryUrl') && hasProperty('mavenRepositoryUsername') && hasProperty('mavenRepositoryPassword') - -evaluationDependsOn(':stringmetric-core') - -dependencies { - compile project(':stringmetric-core') - - testCompile project(':stringmetric-core').sourceSets.test.output -} - -sourceSets { - main { - output.resourcesDir "${project.buildDir}/classes/main" - - java { - srcDir 'source/core/java' - } - resources { - srcDir 'source/core/resource' - } - scala { - srcDir 'source/core/scala' - } - } - test { - output.resourcesDir "${project.buildDir}/classes/test" - - java { - srcDir 'source/test/java' - } - resources { - srcDir 'source/test/resource' - } - scala { - srcDir 'source/test/scala' - } - } -} - -task tar(description: 'Assembles a compressed tar archive of source files.', dependsOn: [':stringmetric-cli:jar', ':stringmetric-core:jar']) { - ext.sourcePath = "${project.projectDir}/source/core/scala" - ext.outputPath = "${project.buildDir}" - ext.workingPath = "${project.buildDir}/${project.name}" - - inputs.dir new File(sourcePath) - outputs.dir new File(outputPath, 'generated') - outputs.upToDateWhen { - new File(workingPath).isDirectory() - } - - doLast { - // Clean up working directory and tar from last execution, should they exist. - ant.delete(dir: workingPath, failOnError: false) - ant.delete(file: "${project.buildDir}/${project.name}.tar.gz", failOnError: false) - - // Create project working directory. - ant.mkdir(dir: workingPath) - - // Create scalascript header file. - ant.echo(file: "${workingPath}/scalascript.sh", message: '#!/bin/bash\ndir="`dirname \\"$0\\"`"\ndir="`( cd \\"$dir\\" && pwd )`"\ncp=`echo $dir/*.jar|sed \'s/ /:/g\'`\nexec scala -classpath "$cp" -savecompiled "$0" "$@"\n!#\n//') - - // Copy source files to working directory. - ant.copy(toDir: workingPath, force: true, overwrite: true) { - fileset(dir: sourcePath) { - exclude(name: '**/cli/*.scala') - exclude(name: '**/package.scala') - } - filterchain { - concatfilter(prepend: "${workingPath}/scalascript.sh") - } - } - - // Delete scalascript header file. - ant.delete(file: "${workingPath}/scalascript.sh") - - // Flatten and remove file extension. - ant.move(toDir: workingPath) { - fileset(dir: workingPath) - chainedmapper { - mapper(type: 'flatten') - mapper(from: '*.scala', to: '*', type: 'glob') - } - } - - // Clean up emtpy folder(s) from flatten. - ant.delete(dir: "${workingPath}/org", includeEmptyDirs: true) - - // Copy project jars into place. - ant.copy(toDir: workingPath, force: true, overwrite: true) { - fileset(dir: "${project.buildDir}/libs") - } - ant.copy(toDir: workingPath, force: true, overwrite: true) { - fileset(dir: "${project(':stringmetric-core').buildDir}/libs") - } - - // Assemble compressed tar. - ant.tar(compression: 'gzip', destFile: "${project.buildDir}/${project.name}.tar.gz") { - tarfileset(dir: workingPath, fileMode: 755, prefix: project.name) - } - } -} - -if (isMavenDeployable) { - signing { - sign configurations.archives - } - - task scaladocJar(type: Jar, dependsOn: scaladoc) { - classifier = 'javadoc' - from "${project.buildDir}/docs/scaladoc" - } - - task sourceJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - artifacts { - archives jar - archives scaladocJar - archives sourceJar - } - - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: mavenRepositoryUrl) { - authentication(userName: mavenRepositoryUsername, password: mavenRepositoryPassword) - } - - pom.project { - description "${parent.project.description}" - groupId "${parent.project.group}" - name "${project.name}" - packaging 'jar' - url "${parent.project.url}" - version "${parent.project.version}" - - developers { - developer { - id 'rockymadden' - name 'Rocky Madden' - } - } - - licenses { - license { - name 'Apache License v2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - - scm { - url "${parent.project.scm}" - connection "${parent.project.scm}" - } - } - } - } - } -}
\ No newline at end of file diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/Command.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/Command.scala deleted file mode 100755 index fedc0d9..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/Command.scala +++ /dev/null @@ -1,24 +0,0 @@ -package com.rockymadden.stringmetric.cli - -/** Defines the traits and provides basic implementations of a command. Commands are always implemented as objects. */ -trait Command { - def help(): Unit - - final def error(error: Throwable, options: OptionMap): Unit = - if (!isUnitTest(options)) { - println(error.getMessage) - sys.exit(1) - } else throw error - - def execute(options: OptionMap): Unit - - final def exit(options: OptionMap): Unit = if (!isUnitTest(options)) sys.exit(0) - - final protected[this] def isDebug(options: OptionMap): Boolean = - (options.contains('d) || (options.contains('debug) && options.get('debug) != "false")) - - final protected[this] def isUnitTest(options: OptionMap): Boolean = - (options.contains('ut) || (options.contains('unitTest) && options.get('unitTest) != "false")) - - def main(args: Array[String]): Unit -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionMap.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionMap.scala deleted file mode 100755 index 79aea0b..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionMap.scala +++ /dev/null @@ -1,38 +0,0 @@ -package com.rockymadden.stringmetric.cli - -import scala.annotation.tailrec - -object OptionMap { - def apply(args: Array[String]): OptionMap = apply(args: _*) - - def apply(varargs: String*): OptionMap = { - @tailrec - def next(om: OptionMap, a: List[String]): OptionMap = { - val double = """^(--[a-zA-Z0-9]+)(=[a-zA-Z0-9\.\-_]+)?""".r - val single = """^(-[a-zA-Z0-9]+)(=[a-zA-Z0-9\.\-_]+)?""".r - val less = """([a-zA-Z0-9/\-_\$\.]+)""".r - - a match { - // Empty, return. - case Nil => om - // Double dash options without value. - case double(k, null) :: t => next(om + (Symbol(k.tail.tail) -> ""), t) - // Double dash options with value. - case double(k, v) :: t => next(om + (Symbol(k.tail.tail) -> v.tail), t) - // Single dash options without value. - case single(k, null) :: t => next(om + (Symbol(k.tail) -> ""), t) - // Single dash options with value. Value is discarded. - case single(k, v) :: t => next(om + (Symbol(k.tail) -> ""), t) - // Dashless options. - case less(v) :: t if v.head != '-' => - if (om.contains('dashless)) - next((om - 'dashless) + ('dashless -> (om('dashless).self + " " + v.trim)), t) - else next(om + ('dashless -> v.trim), t) - // Invalid option, ignore. - case _ :: t => next(om, t) - } - } - - next(Map.empty[Symbol, OptionString], varargs.toList) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionString.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionString.scala deleted file mode 100755 index 7a1350d..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/OptionString.scala +++ /dev/null @@ -1,30 +0,0 @@ -package com.rockymadden.stringmetric.cli - -import scala.language.implicitConversions - -class OptionString(val self: String) - -object OptionString { - implicit def OptionStringToArray(optionString: OptionString): Array[String] = - if (optionString.self.length == 0) Array.empty[String] else optionString.self.split(" ") - - implicit def OptionStringToBigDecimal(optionString: OptionString): BigDecimal = BigDecimal(optionString.self) - - implicit def OptionStringToBigInt(optionString: OptionString): BigInt = BigInt(optionString.self) - - implicit def OptionStringToDouble(optionString: OptionString): Double = optionString.self.toDouble - - implicit def OptionStringToFloat(optionString: OptionString): Float = optionString.self.toFloat - - implicit def OptionStringToInt(optionString: OptionString): Int = optionString.self.toInt - - implicit def OptionStringToLong(optionString: OptionString): Long = optionString.self.toLong - - implicit def OptionStringToShort(optionString: OptionString): Short = optionString.self.toShort - - implicit def OptionStringToString(optionString: OptionString): String = optionString.self - - implicit def StringToOptionString(string: String): OptionString = apply(string) - - def apply(string: String): OptionString = new OptionString(string) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/package.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/package.scala deleted file mode 100755 index cbaba97..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/package.scala +++ /dev/null @@ -1,13 +0,0 @@ -package com.rockymadden.stringmetric - -import scala.language.implicitConversions - -/** - * Provides core CLI functionality. Note that some things might look sloppy (e.g. access modifiers, broad imports, - * repetitive imports, etc), but are required because of the way scalascript is ultimately compiled. - */ -package object cli { - type OptionMap = Map[Symbol, OptionString] - - implicit def StringArrayToOptionMap(stringArray: Array[String]): OptionMap = OptionMap(stringArray) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithm.scala deleted file mode 100755 index d0b3812..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithm.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.MetaphoneAlgorithm - -/** - * The metaphonealgorithm [[com.rockymadden.stringmetric.cli.Command]]. Returns the phonetic representation of the - * passed string, per the Metaphone algorithm. - */ -object metaphonealgorithm extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the phonetic representation of the passed string, per the Metaphone algorithm." + ls + ls + - "Syntax:" + ls + - tab + "metaphonealgorithm [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = - println(MetaphoneAlgorithm.compute(opts('dashless)).getOrElse("not computable")) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetric.scala deleted file mode 100755 index 98ac85c..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.MetaphoneMetric - -/** - * The metaphonemetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to determine if they are - * phonetically similarly, per the Metaphone algorithm. - */ -object metaphonemetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to determine if they are phonetically similarly, per the Metaphone algorithm." + ls + ls + - "Syntax:" + ls + - tab + "metaphonemetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - - println(MetaphoneMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithm.scala deleted file mode 100755 index 0770ba5..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithm.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.NysiisAlgorithm - -/** - * The nysiisalgorithm [[com.rockymadden.stringmetric.cli.Command]]. Returns the phonetic representation of the passed - * string, per the NYSIIS algorithm. - */ -object nysiisalgorithm extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 1) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the phonetic representation of the passed string, per the NYSIIS algorithm." + ls + ls + - "Syntax:" + ls + - tab + "nysiisalgorithm [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = - println(NysiisAlgorithm.compute(options('dashless)).getOrElse("not computable")) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetric.scala deleted file mode 100755 index 95ece48..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.NysiisMetric - -/** - * The nysiismetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to determine if they are - * phonetically similarly, per the NYSIIS algorithm. - */ -object nysiismetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to determine if they are phonetically similarly, per the NYSIIS algorithm." + ls + ls + - "Syntax:" + ls + - tab + "nysiismetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - - println(NysiisMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithm.scala deleted file mode 100755 index e155cbf..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithm.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.RefinedNysiisAlgorithm - -/** - * The refinednysiisalgorithm [[com.rockymadden.stringmetric.cli.Command]]. Returns the phonetic representation of the - * passed string, per the refined NYSIIS algorithm. - */ -object refinednysiisalgorithm extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the phonetic representation of the passed string, per the refined NYSIIS algorithm." + ls + ls + - "Syntax:" + ls + - tab + "refinednysiisalgorithm [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = - println(RefinedNysiisAlgorithm.compute(opts('dashless)).getOrElse("not computable")) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetric.scala deleted file mode 100755 index 3c32291..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.RefinedNysiisMetric - -/** - * The refinednysiismetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to determine if they are - * phonetically similarly, per the refined NYSIIS algorithm. - */ -object refinednysiismetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to determine if they are phonetically similarly, per the refined NYSIIS algorithm." + ls + ls + - "Syntax:" + ls + - tab + "refinednysiismetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(RefinedNysiisMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithm.scala deleted file mode 100755 index f5a89a8..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithm.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.RefinedSoundexAlgorithm - -/** - * The refinedsoundexalgorithm [[com.rockymadden.stringmetric.cli.Command]]. Returns the phonetic representation of the - * passed string, per the refined Soundex algorithm. - */ -object refinedsoundexalgorithm extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the phonetic representation of the passed string, per the refined Soundex algorithm." + ls + ls + - "Syntax:" + ls + - tab + "refinedsoundexalgorithm [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = - println(RefinedSoundexAlgorithm.compute(opts('dashless)).getOrElse("not computable")) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetric.scala deleted file mode 100755 index e5ea4b4..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.RefinedSoundexMetric - -/** - * The refinedsoundexmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to determine if they are - * phonetically similarly, per the refined Soundex algorithm. - */ -object refinedsoundexmetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to determine if they are phonetically similarly, per the refined Soundex algorithm." + ls + ls + - "Syntax:" + ls + - tab + "refinedsoundexmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(RefinedSoundexMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithm.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithm.scala deleted file mode 100755 index 9883eb3..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithm.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.SoundexAlgorithm - -/** - * The soundexalgorithm [[com.rockymadden.stringmetric.cli.Command]]. Returns the phonetic representation of the passed - * string, per the Soundex algorithm. - */ -object soundexalgorithm extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the phonetic representation of the passed string, per the Soundex algorithm." + ls + ls + - "Syntax:" + ls + - tab + "soundexalgorithm [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = - println(SoundexAlgorithm.compute(opts('dashless)).getOrElse("not computable")) -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetric.scala deleted file mode 100755 index 01d070e..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.phonetic.SoundexMetric - -/** - * The soundexmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to determine if they are - * phonetically similarly, per the Soundex algorithm. - */ -object soundexmetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to determine if they are phonetically similarly, per the Soundex algorithm." + ls + ls + - "Syntax:" + ls + - tab + "soundexmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(SoundexMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetric.scala deleted file mode 100755 index 5d0e234..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetric.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.DiceSorensenMetric - -/** - * The dicesorensenmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the similarity of two strings using the - * Dice / Sorensen coefficient. - */ -object dicesorensenmetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2 - && opts.contains('n) && (opts('n): Int) >= 1) { - - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the similarity of two strings using the Dice / Sorensen coefficient." + ls + ls + - "Syntax:" + ls + - tab + "dicesorensenmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." + - tab + "--n" + ls + - tab + tab + "The n-gram size, traditionally 2." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - val n: Int = opts('n) - - println(DiceSorensenMetric.compare(strings(0), strings(1))(n).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetric.scala deleted file mode 100755 index c03293f..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.HammingMetric - -/** - * The hammingmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the number of characters that two equal - * length strings are different from one another. - */ -object hammingmetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the number of characters that two equal length strings are different from one another." + ls + ls + - "Syntax:" + ls + - tab + "hammingmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(HammingMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetric.scala deleted file mode 100755 index 1f1e123..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetric.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.JaccardMetric - -/** - * The jaccardmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the similarity of two strings using the - * Jaccard coefficient. - */ -object jaccardmetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2 - && opts.contains('n) && (opts('n): Int) >= 1) { - - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the similarity of two strings using the Jaccard coefficient." + ls + ls + - "Syntax:" + ls + - tab + "jaccardmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." + - tab + "--n" + ls + - tab + tab + "The n-gram size." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - val n: Int = opts('n) - - println(JaccardMetric.compare(strings(0), strings(1))(n).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarometric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarometric.scala deleted file mode 100755 index fcb6aa2..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarometric.scala +++ /dev/null @@ -1,41 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.JaroMetric - -/** The jarometric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to calculate the Jaro distance. */ -object jarometric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to calculate the Jaro distance." + ls + ls + - "Syntax:" + ls + - tab + "jarometric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(JaroMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetric.scala deleted file mode 100755 index b925c2d..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.JaroWinklerMetric - -/** - * The jarowinklermetric [[com.rockymadden.stringmetric.cli.Command]]. Compares two strings to calculate the - * Jaro-Winkler distance. - */ -object jarowinklermetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares two strings to calculate the Jaro-Winkler distance." + ls + ls + - "Syntax:" + ls + - tab + "jarowinklermetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - - println(JaroWinklerMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetric.scala deleted file mode 100755 index 6146750..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetric.scala +++ /dev/null @@ -1,45 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.LevenshteinMetric - -/** - * The levenshteinmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the number of characters that two - * strings are different from one another via insertion, deletion, and substitution. - */ -object levenshteinmetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2) { - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the number of characters that two strings are different from one another via insertion, deletion, " + - "and substitution." + ls + ls + - "Syntax:" + ls + - tab + "levenshteinmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - - println(LevenshteinMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetric.scala deleted file mode 100755 index af0634f..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetric.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.NGramMetric - -/** - * The ngrammetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the similarity of two strings using an N-Gram - * similarity index. - */ -object ngrammetric extends Command { - override def main(args: Array[String]): Unit = { - val options: OptionMap = args - - try - if (options.contains('h) || options.contains('help)) { - help() - exit(options) - } else if (options.contains('dashless) && (options('dashless): Array[String]).length == 2 - && options.contains('n) && (options('n): Int) >= 1) { - - execute(options) - exit(options) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, options) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the similarity of two strings using an N-Gram similarity index." + ls + ls + - "Syntax:" + ls + - tab + "ngrammetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and options." + - tab + "--n" + ls + - tab + tab + "The n." - ) - } - - override def execute(options: OptionMap): Unit = { - val strings: Array[String] = options('dashless) - val n: Int = options('n) - - println(NGramMetric.compare(strings(0), strings(1))(n).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetric.scala deleted file mode 100755 index 2c670c5..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetric.scala +++ /dev/null @@ -1,49 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.OverlapMetric - -/** - * The overlapmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the similarity of two strings using the - * overlap coefficient. - */ -object overlapmetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2 - && opts.contains('n) && (opts('n): Int) >= 1) { - - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the similarity of two strings using the overlap coefficient." + ls + ls + - "Syntax:" + ls + - tab + "overlapmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." + - tab + "--n" + ls + - tab + tab + "The n-gram size." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - val n: Int = opts('n) - - println(OverlapMetric.compare(strings(0), strings(1))(n).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetric.scala deleted file mode 100755 index f69c222..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetric.scala +++ /dev/null @@ -1,44 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.RatcliffObershelpMetric - -/** - * The ratcliffobershelpmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the similarity of two strings - * using the Ratcliff / Obershelp similarity index. - */ -object ratcliffobershelpmetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2) { - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the similarity of two strings using the Ratcliff / Obershelp similarity index." + ls + ls + - "Syntax:" + ls + - tab + "ratcliffobershelpmetric [Options] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - - println(RatcliffObershelpMetric.compare(strings(0), strings(1)).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetric.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetric.scala deleted file mode 100755 index d675db1..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetric.scala +++ /dev/null @@ -1,62 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.similarity.WeightedLevenshteinMetric -import scala.math.BigDecimal - -/** - * The weightedlevenshteinmetric [[com.rockymadden.stringmetric.cli.Command]]. Compares the number of characters that - * two strings are different from one another via insertion, deletion, and substitution. Allows the invoker to indicate - * the weight each operation takes. - */ -object weightedlevenshteinmetric extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 2 - && opts.contains('deleteWeight) && (opts('deleteWeight): Double) >= 0 - && opts.contains('insertWeight) && (opts('insertWeight): Double) >= 0 - && opts.contains('substituteWeight) && (opts('substituteWeight): Double) >= 0) { - - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Compares the number of characters that two strings are different from one another via insertion, deletion, " + - "and substitution. Allows the invoker to indicate the weight each operation takes." + ls + ls + - "Syntax:" + ls + - tab + "weightedlevenshteinmetric [Options] --deleteWeight=[double] --insertWeight=[double] --substituteWeight=[double] string1 string2..." + ls + ls + - "Options:" + ls + - tab + "--deleteWeight" + ls + - tab + tab + "The weight given to delete operations." + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." + - tab + "--insertWeight" + ls + - tab + tab + "The weight given to insert operations." + - tab + "--substituteWeight" + ls + - tab + tab + "The weight given to substitute operations." - ) - } - - override def execute(opts: OptionMap): Unit = { - val strings: Array[String] = opts('dashless) - val weights = Tuple3[BigDecimal, BigDecimal, BigDecimal]( - opts('deleteWeight), - opts('insertWeight), - opts('substituteWeight) - ) - - println(WeightedLevenshteinMetric.compare(strings(0), strings(1))(weights).getOrElse("not comparable")) - } -} diff --git a/cli/source/core/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizer.scala b/cli/source/core/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizer.scala deleted file mode 100755 index 99fdbe5..0000000 --- a/cli/source/core/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizer.scala +++ /dev/null @@ -1,58 +0,0 @@ -package com.rockymadden.stringmetric.cli.tokenization - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.tokenization.NGramTokenizer - -/** - * The ngramtokenizer [[com.rockymadden.stringmetric.cli.Command]]. Returns the N-Gram representation of the passed - * string. - */ -object ngramtokenizer extends Command { - override def main(args: Array[String]): Unit = { - val opts: OptionMap = args - - try - if (opts.contains('h) || opts.contains('help)) { - help() - exit(opts) - } else if (opts.contains('dashless) && (opts('dashless): Array[String]).length == 1 - && opts.contains('n) && (opts('n): Int) >= 1) { - - execute(opts) - exit(opts) - } else throw new IllegalArgumentException("Expected valid syntax. See --help.") - catch { case e: Throwable => error(e, opts) } - } - - override def help(): Unit = { - val ls = sys.props("line.separator") - val tab = " " - - println( - "Returns the N-Gram representation of the passed string." + ls + ls + - "Syntax:" + ls + - tab + "ngramtokenizer [Options] string..." + ls + ls + - "Options:" + ls + - tab + "-h, --help" + ls + - tab + tab + "Outputs description, syntax, and opts." + - tab + "--n" + ls + - tab + tab + "The n." - ) - } - - override def execute(opts: OptionMap): Unit = - NGramTokenizer.tokenize(opts('dashless))(opts('n)) match { - // Implicits are a pain here. - case Some(c) => { - val sb = new StringBuilder - - Range(0, c.length).foreach { i => - sb.append(c(i)) - if (i < c.length - 1) sb.append("|") - } - - println(sb.result()) - } - case None => println("not computable") - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala deleted file mode 100755 index 121e2ed..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/OptionMapSpec.scala +++ /dev/null @@ -1,84 +0,0 @@ -package com.rockymadden.stringmetric.cli - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class OptionMapSpec extends ScalaTest { - "OptionMap" should provide { - "apply method" when passed { - "single valid double dashed option" should returns { - "populated Map" in { - val opts: OptionMap = Array("--help") - - (opts('help): String) should equal ("") - } - } - "multiple valid double dashed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array("--help", "--test=test") - - (opts('help): String) should equal ("") - (opts('test): String) should equal ("test") - } - } - "invalid double dashed opts" should returns { - "empty Map" in { - val opts: OptionMap = Array("--help#", "--test%=test") - - opts.keysIterator.length should be (0) - } - } - "single valid single dashed option" should returns { - "populated Map" in { - val opts: OptionMap = Array("-h") - - (opts('h): String) should equal ("") - } - } - "multiple valid single dashed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array("-h", "-i") - - (opts('h): String) should equal ("") - (opts('i): String) should equal ("") - } - } - "invalid single dashed opts" should returns { - "empty Map" in { - val opts: OptionMap = Array("-h-i", "-i#gloo") - - opts.keysIterator.length should be (0) - } - } - "single nameless option" should returns { - "single key populated Map" in { - val opts: OptionMap = Array("filename0") - - (opts('dashless): String).count(_ == ' ') should be (0) - } - } - "multiple single nameless opts" should returns { - "single key populated Map" in { - val opts: OptionMap = Array("filename0", "filename1", "filename2") - - (opts('dashless): String).count(_ == ' ') should be (2) - } - } - "mixed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array( - "-q", "--help", "--test=test", "-go", "filename0", "filename1", "filename2" - ) - - (opts('q): String) should equal ("") - (opts('help): String) should equal ("") - (opts('test): String) should equal ("test") - (opts('go): String) should equal ("") - (opts('dashless): String).count(_ == ' ') should be (2) - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala deleted file mode 100755 index 68bdcf7..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class metaphonealgorithmSpec extends ScalaTest { - "metaphonealgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - metaphonealgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abk\n") - out.reset() - - Console.withOut(out)( - metaphonealgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - metaphonealgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala deleted file mode 100755 index 4e6567e..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class metaphonemetricSpec extends ScalaTest { - "metaphonemetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - metaphonemetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala deleted file mode 100755 index 3683d2d..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class nysiisalgorithmSpec extends ScalaTest { - "nysiisalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - nysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abc\n") - out.reset() - - Console.withOut(out)( - nysiisalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - nysiisalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala deleted file mode 100755 index 6898025..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class nysiismetricSpec extends ScalaTest { - "nysiismetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - nysiismetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala deleted file mode 100755 index f5376fa..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class refinednysiisalgorithmSpec extends ScalaTest { - "refinednysiisalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - refinednysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abc\n") - out.reset() - - Console.withOut(out)( - refinednysiisalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - refinednysiisalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala deleted file mode 100755 index 4b4889d..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class refinednysiismetricSpec extends ScalaTest { - "refinednysiismetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - refinednysiismetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala deleted file mode 100755 index 80a8fd2..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class refinedsoundexalgorithmSpec extends ScalaTest { - "refinedsoundexalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("a013\n") - out.reset() - - Console.withOut(out)( - refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - refinedsoundexalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala deleted file mode 100755 index 42338af..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class refinedsoundexmetricSpec extends ScalaTest { - "refinedsoundexmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - refinedsoundexmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala deleted file mode 100755 index f971d66..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class soundexalgorithmSpec extends ScalaTest { - "soundexalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - soundexalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("a120\n") - out.reset() - - Console.withOut(out)( - soundexalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - soundexalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala deleted file mode 100755 index 82a3f6d..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala +++ /dev/null @@ -1,46 +0,0 @@ -package com.rockymadden.stringmetric.cli.phonetic - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class soundexmetricSpec extends ScalaTest { - "soundexmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - soundexmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala deleted file mode 100755 index db68b68..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class dicesorensenmetricSpec extends ScalaTest { - "dicesorensenmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - dicesorensenmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala deleted file mode 100755 index 28e91ad..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class hammingmetricSpec extends ScalaTest { - "hammingmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - hammingmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("0\n") - out.reset() - - Console.withOut(out)( - hammingmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("3\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - hammingmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala deleted file mode 100755 index 9f7e2b9..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class jaccardmetricSpec extends ScalaTest { - "jaccardmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jaccardmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala deleted file mode 100755 index 980ecff..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class jarometricSpec extends ScalaTest { - "jarometric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print the distance" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - jarometric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jarometric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jarometric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala deleted file mode 100755 index d84f1a5..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class jarowinklermetricSpec extends ScalaTest { - "jarowinklermetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print the distance" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jarowinklermetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala deleted file mode 100755 index ec4c8a7..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class levenshteinmetricSpec extends ScalaTest { - "levenshteinmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("0\n") - out.reset() - - Console.withOut(out)( - levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("3\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - levenshteinmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala deleted file mode 100755 index f969df3..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala +++ /dev/null @@ -1,68 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class ngrammetricSpec extends ScalaTest { - "ngrammetric" should provide { - "main method" when passed { - "valid dashless arguments and valid n argument" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - ngrammetric.main( - Array( - "--unitTest", - "--debug", - "--n=1", - "abc", - "abc" - ) - ) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - ngrammetric.main( - Array( - "--unitTest", - "--debug", - "--n=1", - "abc", - "xyz" - ) - ) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "valid dashless arguments and invalid n argument" should throws { - "IllegalArgumentException" in { - evaluating { - ngrammetric.main( - Array( - "--unitTest", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - ngrammetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala deleted file mode 100755 index d614a77..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class overlapmetricSpec extends ScalaTest { - "overlapmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - overlapmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala deleted file mode 100755 index 8af7793..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala +++ /dev/null @@ -1,39 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class ratcliffobershelpmetricSpec extends ScalaTest { - "ratcliffobershelpmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - ratcliffobershelpmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala deleted file mode 100755 index 41065db..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala +++ /dev/null @@ -1,123 +0,0 @@ -package com.rockymadden.stringmetric.cli.similarity - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class weightedlevenshteinmetricSpec extends ScalaTest { - "weightedlevenshteinmetric" should provide { - "main method" when passed { - "valid dashless arguments and valid weight arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=1", - "--substituteWeight=1", - "abc", - "abc" - ) - ) - ) - - out.toString should equal ("0.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=2", - "--insertWeight=2", - "--substituteWeight=1", - "abc", - "xyz" - ) - ) - ) - - out.toString should equal ("3.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=2", - "--insertWeight=1", - "--substituteWeight=2", - "xyz", - "xyzxyz" - ) - ) - ) - - out.toString should equal ("3.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=2", - "--substituteWeight=2", - "xyzxyz", - "xyz" - ) - ) - ) - - out.toString should equal ("3.0\n") - out.reset() - } - } - "valid dashless arguments and invalid weight arguments" should throws { - "IllegalArgumentException" in { - evaluating { - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--substituteWeight=1", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - - evaluating { - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=q", - "--substituteWeight=1", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - } - } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - weightedlevenshteinmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala deleted file mode 100755 index 8a1ea1d..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenization/ngramtokenizerSpec.scala +++ /dev/null @@ -1,66 +0,0 @@ -package com.rockymadden.stringmetric.cli.tokenization - -import com.rockymadden.stringmetric.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class ngramtokenizerSpec extends ScalaTest { - "ngramtokenizer" should provide { - "main method" when passed { - "valid dashless argument and valid n argument" should executes { - "print N-Gram representation" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - ngramtokenizer.main( - Array( - "--unitTest", - "--debug", - "--n=1", - "abc" - ) - ) - ) - - out.toString should equal ("a|b|c\n") - out.reset() - - Console.withOut(out)( - ngramtokenizer.main( - Array( - "--unitTest", - "--debug", - "--n=2", - "abc" - ) - ) - ) - - out.toString should equal ("ab|bc\n") - out.reset() - } - } - "valid dashless argument and invalid n argument" should throws { - "IllegalArgumentException" in { - evaluating { - ngramtokenizer.main( - Array( - "--unitTest", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - } - } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - ngramtokenizer.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } - } - } - } -} |