Skip to content

Instantly share code, notes, and snippets.

@zeryx
Last active January 5, 2017 21:16
Show Gist options
  • Save zeryx/731395c9f6250485a0ea7c6c44b787a2 to your computer and use it in GitHub Desktop.
Save zeryx/731395c9f6250485a0ea7c6c44b787a2 to your computer and use it in GitHub Desktop.
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
}
}
case class Predict(text: String, namespace: Option[String]) {
...
...
}
object Predict{
implicit def ClusterCodec: CodecJson[Predict] =
casecodec2(Predict.apply, Predict.unapply)(
"text",
"namespace"
)
}
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