Skip to content

Instantly share code, notes, and snippets.

@shubham0204
Last active May 1, 2019 04:05
Show Gist options
  • Save shubham0204/ca276a798b0fc5eed4ede95bbe07f547 to your computer and use it in GitHub Desktop.
Save shubham0204/ca276a798b0fc5eed4ede95bbe07f547 to your computer and use it in GitHub Desktop.
fun classifySequence ( sequence : IntArray ): FloatArray {
val interpreter = Interpreter( loadModelFile() )
val inputs : Array<FloatArray> = arrayOf( sequence.map{ it.toFloat() }.toFloatArray() )
val outputs : Array<FloatArray> = arrayOf( floatArrayOf( 0.0f , 0.0f ) )
interpreter.run( inputs , outputs )
return outputs[0]
}
val tokenizedMessage = tokenize( message_text.text.toString().toLowerCase().trim() )
val paddedMessage = padSequence( tokenizedMessage )
val results = classifySequence( paddedMessage )
val class1 = results[0]
val class2 = results[1]
result_text.text = "SPAM : $class2\nNOT SPAM : $class1 "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment