Last active
January 5, 2017 21:16
-
-
Save zeryx/731395c9f6250485a0ea7c6c44b787a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply(input: String): String = { | |
val output = Utils.Read(input) match { | |
case Some(predict: Predict) => { | |
println(predict) | |
predict.process(client) | |
} | |
case Some(train: Training) => { | |
println(train) | |
train.process(client) | |
} | |
case _ => { | |
println(input) | |
Right(new AlgorithmException(s"failed to parse")) | |
} | |
} | |
output match { | |
case Left(result) => Utils.Write(result).nospaces | |
case Right(err) => throw err | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Predict(text: String, namespace: Option[String]) { | |
... | |
... | |
} | |
object Predict{ | |
implicit def ClusterCodec: CodecJson[Predict] = | |
casecodec2(Predict.apply, Predict.unapply)( | |
"text", | |
"namespace" | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Training(labelData: Option[List[DataPoint]], labelFile: Option[String], namespace: Option[String]){ | |
... | |
... | |
} | |
object Training{ | |
implicit def ClusterCodec: CodecJson[Training] = | |
casecodec3(Training.apply, Training.unapply)( | |
"labelData", | |
"labelFile", | |
"namespace" | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment