-
-
Save Jacoby6000/c6a87477237fdd37ee3dc5acf7778031 to your computer and use it in GitHub Desktop.
This file contains 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
package algorithmia.TechSupport | |
import algorithmia.TechSupport.Classes.DataPoint | |
import argonaut.Argonaut._ | |
import argonaut.CodecJson | |
/** | |
* Created by james on 05/01/17. | |
*/ | |
sealed trait Input | |
object Input { | |
implicit def inputCodec = | |
CodecJson[Input]( | |
encoder = { | |
case train: Train => Train.trainCodec.encode(train) | |
case predict: Predict => Predict.predictCodec.encode(predict) | |
}, | |
decoder = json => Predict.predictCodec.decode(json) ||| Train.trainCodec.decode(json) | |
) | |
} | |
case class Train(labelData: Option[List[DataPoint]], labelFile: Option[String], namespace: Option[String]) extends Input | |
case class Predict(text: String, namespace: Option[String]) extends Input | |
object Train { | |
implicit def trainCodec: CodecJson[Train] = | |
casecodec3(Train.apply, Train.unapply)( | |
"labelData", | |
"labelFile", | |
"namespace" | |
) | |
} | |
object Predict{ | |
implicit def predictCodec: CodecJson[Predict] = | |
casecodec2(Predict.apply, Predict.unapply)( | |
"text", | |
"namespace" | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment