public override void OutputToCmd(OutputStream outputStream) { try { PrintWriter pw = IOUtils.EncodedOutputStreamPrintWriter(outputStream, null, true); classifier.ClassifyAndWriteAnswers(data, featurizedData, pw, classifier.MakeReaderAndWriter()); } catch (IOException ex) { throw new RuntimeIOException(ex); } }
/// <exception cref="System.Exception"/> public static void Main(string[] args) { StringUtils.LogInvocationString(log, args); Properties props = StringUtils.ArgsToProperties(args); CRFClassifier <CoreLabel> crf = new CRFClassifier <CoreLabel>(props); string inputFile = crf.flags.trainFile; if (inputFile == null) { log.Info("Please provide input file using -trainFile"); System.Environment.Exit(-1); } string outputFile = crf.flags.exportFeatures; if (outputFile == null) { log.Info("Please provide output file using -exportFeatures"); System.Environment.Exit(-1); } Edu.Stanford.Nlp.IE.Crf.CRFFeatureExporter <CoreLabel> featureExporter = new Edu.Stanford.Nlp.IE.Crf.CRFFeatureExporter <CoreLabel>(crf); ICollection <IList <CoreLabel> > docs = crf.MakeObjectBankFromFile(inputFile, crf.MakeReaderAndWriter()); crf.MakeAnswerArraysAndTagIndex(docs); featureExporter.PrintFeatures(outputFile, docs); }