Created
August 1, 2012 07:35
-
-
Save fozziethebeat/3224640 to your computer and use it in GitHub Desktop.
Revisions
-
fozziethebeat created this gist
Aug 1, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ import edu.stanford.nlp.ie.crf.CRFClassifier import edu.stanford.nlp.ling.CoreLabel import edu.stanford.nlp.ling.Word import edu.stanford.nlp.util.StringUtils import edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter import edu.stanford.nlp.sequences.PlainTextDocumentReaderAndWriter.OutputStyle import scala.collection.JavaConversions.collectionAsScalaIterable import scala.collection.JavaConversions.seqAsJavaList import scala.io.Source object NamedEntityRecognitionExample { def main(args: Array[String]) { val props = StringUtils.argsToProperties(args) val crf = new CRFClassifier[CoreLabel](props) val loadPath = crf.flags.loadClassifier; val textFile = crf.flags.textFile; crf.loadClassifierNoExceptions(loadPath, props) val readerAndWriter = new PlainTextDocumentReaderAndWriter[CoreLabel]() readerAndWriter.init(crf.flags) for (line<- Source.fromFile(textFile).getLines) { println(crf.classify(line) .map(tagged => readerAndWriter.getAnswers(tagged, OutputStyle.INLINE_XML, true)) .mkString(" ")) } } }