Skip to content

Instantly share code, notes, and snippets.

@sadv1r
Created April 30, 2016 11:07
Show Gist options
  • Save sadv1r/9db9b4e31f388a7cf925eaeb03aa4dc1 to your computer and use it in GitHub Desktop.
Save sadv1r/9db9b4e31f388a7cf925eaeb03aa4dc1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env kscript
//DEPS org.apache.opennlp:opennlp-tools:1.5.3,org.slf4j:slf4j-simple:1.7.7
import opennlp.tools.doccat.DoccatModel
import opennlp.tools.doccat.DocumentCategorizerME
import opennlp.tools.doccat.DocumentSampleStream
import opennlp.tools.util.PlainTextByLineStream
import java.io.FileInputStream
/**
* Created on 4/30/16.
*
* @author sadv1r
* @version 0.1
*/
println("Hello Kotlin script")
val dataIn = FileInputStream("tweets.txt")
val lineStream = PlainTextByLineStream(dataIn, "UTF-8")
val sampleStream = DocumentSampleStream(lineStream)
val cutoff = 2
val trainingIterations = 30
val model = DocumentCategorizerME.train("en", sampleStream, cutoff,
trainingIterations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment