From b08f381f72e4a1b2ff1cbf43b16b1608ebf2ad32 Mon Sep 17 00:00:00 2001 From: hrj Date: Sat, 8 Jun 2019 11:43:17 +0530 Subject: [PATCH] add an app to generate samples --- src/main/scala/lc/Main.scala | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/scala/lc/Main.scala b/src/main/scala/lc/Main.scala index 7c20e45..131cca7 100644 --- a/src/main/scala/lc/Main.scala +++ b/src/main/scala/lc/Main.scala @@ -58,6 +58,12 @@ class Captcha(throttle: Int) { image } + def generateChallengeSamples() = { + providers.map {case (key, provider) => + (key, provider.returnChallenge()) + } + } + def generateChallenge(param: Parameters): String = { //TODO: eval params to choose a provider val providerMap = getProvider() @@ -202,3 +208,17 @@ object LCFramework{ } } +object MakeSamples { + def main(args: scala.Array[String]) { + val captcha = new Captcha(2) + val samples = captcha.generateChallengeSamples() + samples.foreach {case (key, sample) => + val extensionMap = Map("image/png" -> "png", "image/gif" -> "gif") + println(key + ": " + sample) + + val outStream = new java.io.FileOutputStream("samples/"+key+"."+extensionMap(sample.contentType)) + outStream.write(sample.content) + outStream.close + } + } +}