diff options
Diffstat (limited to 'cli')
-rwxr-xr-x | cli/source/main/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizer.scala | 31 | ||||
-rwxr-xr-x | cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala | 64 |
2 files changed, 0 insertions, 95 deletions
diff --git a/cli/source/main/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizer.scala b/cli/source/main/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizer.scala deleted file mode 100755 index cbd33d7..0000000 --- a/cli/source/main/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizer.scala +++ /dev/null @@ -1,31 +0,0 @@ -package com.rockymadden.stringmetric.cli.tokenize - -import com.rockymadden.stringmetric.cli._ -import com.rockymadden.stringmetric.tokenize.NGramTokenizer - -case object ngramtokenizer extends Command( - (opts) => - "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.", - (opts) => opts.contains('dashless) && (opts('dashless): Array[String]).length == 1 && - opts.contains('n) && (opts('n): Int) >= 1, - (opts) => NGramTokenizer(opts('n)).tokenize(opts('dashless)) match { - case Some(c) => { - val sb = new StringBuilder - - Range(0, c.length).foreach { i => - sb.append(c(i)) - if (i < c.length - 1) sb.append("|") - } - - sb.result() - } - case None => "not computable" - } -) diff --git a/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala b/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala deleted file mode 100755 index 552fcf4..0000000 --- a/cli/source/test/scala/com/rockymadden/stringmetric/cli/tokenize/ngramtokenizerSpec.scala +++ /dev/null @@ -1,64 +0,0 @@ -package com.rockymadden.stringmetric.cli.tokenize - -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] - } - } - } -}} |