PlainTextDocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<>(); ObjectBank<List<CoreLabel>> ob = new ObjectBank<>(new ReaderIteratorFactory(reader), readerAndWriter); PrintWriter pw = new PrintWriter(writer);
public static void main(String[] args) throws Exception { Properties props = StringUtils.argsToProperties(args); NumberSequenceClassifier nsc = new NumberSequenceClassifier(props, true, props); String trainFile = nsc.flags.trainFile; String testFile = nsc.flags.testFile; String textFile = nsc.flags.textFile; String loadPath = nsc.flags.loadClassifier; String serializeTo = nsc.flags.serializeTo; if (loadPath != null) { nsc.loadClassifierNoExceptions(loadPath); nsc.flags.setProperties(props); } else if (trainFile != null) { nsc.train(trainFile); } if (serializeTo != null) { nsc.serializeClassifier(serializeTo); } if (testFile != null) { nsc.classifyAndWriteAnswers(testFile, nsc.makeReaderAndWriter(), true); } if (textFile != null) { DocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<>(); nsc.classifyAndWriteAnswers(textFile, readerAndWriter, false); } } // end main
new PlainTextDocumentReaderAndWriter<>(); cmm.classifyAndWriteAnswers(textFile, readerAndWriter, false);
/** * Classify the contents of a file. * * @param filename * Contains the sentence(s) to be classified. * @return {@link List} of classified List of IN. */ public List<List<IN>> classifyFile(String filename) { DocumentReaderAndWriter<IN> readerAndWriter = new PlainTextDocumentReaderAndWriter<IN>(); readerAndWriter.init(flags); ObjectBank<List<IN>> documents = makeObjectBankFromFile(filename, readerAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { // System.err.println(document); classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { sentence.add(wi); // System.err.println(wi); } result.add(sentence); } return result; }
/** * Classify the tokens in a String. Each sentence becomes a separate document. * * @param str * A String with tokens in one or more sentences of text to be * classified. * @return {@link List} of classified sentences (each a List of something that * extends {@link CoreMap}). */ public List<List<IN>> classify(String str) { DocumentReaderAndWriter<IN> readerAndWriter = new PlainTextDocumentReaderAndWriter<IN>(); readerAndWriter.init(flags); ObjectBank<List<IN>> documents = makeObjectBankFromString(str, readerAndWriter); List<List<IN>> result = new ArrayList<List<IN>>(); for (List<IN> document : documents) { classify(document); List<IN> sentence = new ArrayList<IN>(); for (IN wi : document) { // TaggedWord word = new TaggedWord(wi.word(), wi.answer()); // sentence.add(word); sentence.add(wi); } result.add(sentence); } return result; }
PlainTextDocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<>(); ObjectBank<List<CoreLabel>> ob = new ObjectBank<>(new ReaderIteratorFactory(reader), readerAndWriter); PrintWriter pw = new PrintWriter(writer);
new PlainTextDocumentReaderAndWriter<IN>(); readerAndWriter.init(flags);
PlainTextDocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<>(); ObjectBank<List<CoreLabel>> ob = new ObjectBank<>(new ReaderIteratorFactory(reader), readerAndWriter); PrintWriter pw = new PrintWriter(writer);
PlainTextDocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<CoreLabel>(); ObjectBank<List<CoreLabel>> ob = new ObjectBank<List<CoreLabel>>(new ReaderIteratorFactory(reader), readerAndWriter); PrintWriter pw = new PrintWriter(writer);
new PlainTextDocumentReaderAndWriter<IN>(); readerAndWriter.init(flags); ObjectBank<List<IN>> documents =
if (config.getSGML()) { PlainTextDocumentReaderAndWriter readerAndWriter = new PlainTextDocumentReaderAndWriter(); ObjectBank<List<CoreLabel>> ob = new ObjectBank<List<CoreLabel>>(new ReaderIteratorFactory(reader), readerAndWriter); PrintWriter pw = new PrintWriter(writer);
public static void main(String[] args) throws Exception { Properties props = StringUtils.argsToProperties(args); NumberSequenceClassifier nsc = new NumberSequenceClassifier(props, true, props); String trainFile = nsc.flags.trainFile; String testFile = nsc.flags.testFile; String textFile = nsc.flags.textFile; String loadPath = nsc.flags.loadClassifier; String serializeTo = nsc.flags.serializeTo; if (loadPath != null) { nsc.loadClassifierNoExceptions(loadPath); nsc.flags.setProperties(props); } else if (trainFile != null) { nsc.train(trainFile); } if (serializeTo != null) { nsc.serializeClassifier(serializeTo); } if (testFile != null) { nsc.classifyAndWriteAnswers(testFile, nsc.makeReaderAndWriter(), true); } if (textFile != null) { DocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<>(); nsc.classifyAndWriteAnswers(textFile, readerAndWriter, false); } } // end main
public static void main(String[] args) throws Exception { Properties props = StringUtils.argsToProperties(args); NumberSequenceClassifier nsc = new NumberSequenceClassifier(props, true, props); String trainFile = nsc.flags.trainFile; String testFile = nsc.flags.testFile; String textFile = nsc.flags.textFile; String loadPath = nsc.flags.loadClassifier; String serializeTo = nsc.flags.serializeTo; if (loadPath != null) { nsc.loadClassifierNoExceptions(loadPath); nsc.flags.setProperties(props); } else if (trainFile != null) { nsc.train(trainFile); } if (serializeTo != null) { nsc.serializeClassifier(serializeTo); } if (testFile != null) { nsc.classifyAndWriteAnswers(testFile, nsc.makeReaderAndWriter()); } if (textFile != null) { DocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<CoreLabel>(); nsc.classifyAndWriteAnswers(textFile, readerAndWriter); } } // end main
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { Properties props = StringUtils.argsToProperties(args); NumberSequenceClassifier nsc = new NumberSequenceClassifier(props, true); String trainFile = nsc.flags.trainFile; String testFile = nsc.flags.testFile; String textFile = nsc.flags.textFile; String loadPath = nsc.flags.loadClassifier; String serializeTo = nsc.flags.serializeTo; if (loadPath != null) { nsc.loadClassifierNoExceptions(loadPath); nsc.flags.setProperties(props); } else if (trainFile != null) { nsc.train(trainFile); } if (serializeTo != null) { nsc.serializeClassifier(serializeTo); } if (testFile != null) { nsc.classifyAndWriteAnswers(testFile, nsc.makeReaderAndWriter()); } if (textFile != null) { DocumentReaderAndWriter readerAndWriter = new PlainTextDocumentReaderAndWriter(); nsc.classifyAndWriteAnswers(textFile, readerAndWriter); } } // end main
new PlainTextDocumentReaderAndWriter(); readerAndWriter.init(crf.flags); crf.classifyAndWriteAnswers(textFile, readerAndWriter);
new PlainTextDocumentReaderAndWriter<>(); cmm.classifyAndWriteAnswers(textFile, readerAndWriter, false);
new PlainTextDocumentReaderAndWriter<CoreLabel>(); cmm.classifyAndWriteAnswers(textFile, readerAndWriter);
new PlainTextDocumentReaderAndWriter(); cmm.classifyAndWriteAnswers(textFile, readerAndWriter);