Last active
May 1, 2019 04:05
-
-
Save shubham0204/ca276a798b0fc5eed4ede95bbe07f547 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
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