/** * Initialize this object using values in Properties object. The properties * are printed to stderr as it works. * * @param props The properties object used for initialization */ public final void setProperties(Properties props) { setProperties(props, true); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public SeqClassifierFlags(Properties props) { setProperties(props, true); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization * @param printProps Whether to print the properties on construction */ public SeqClassifierFlags(Properties props, boolean printProps) { setProperties(props, printProps); }
/** Load a classifier from the given Stream. * <i>Implementation note: </i> This method <i>does not</i> close the * Stream that it reads from. * * @param ois The ObjectInputStream to load the serialized classifier from * * @throws IOException If there are problems accessing the input stream * @throws ClassCastException If there are problems interpreting the serialized data * @throws ClassNotFoundException If there are problems interpreting the serialized data * */ @SuppressWarnings("unchecked") @Override public void loadClassifier(ObjectInputStream ois, Properties props) throws ClassCastException, IOException, ClassNotFoundException { classifier = (LinearClassifier<String, String>) ois.readObject(); flags = (SeqClassifierFlags) ois.readObject(); Object featureFactory = ois.readObject(); if (featureFactory instanceof List) { featureFactories = ErasureUtils.uncheckedCast(featureFactory); } else if (featureFactory instanceof FeatureFactory) { featureFactories = Generics.newArrayList(); featureFactories.add((FeatureFactory) featureFactory); } if (props != null) { flags.setProperties(props); } reinit(); classIndex = (Index<String>) ois.readObject(); answerArrays = (Set<List<String>>) ois.readObject(); knownLCWords = (MaxSizeConcurrentHashSet<String>) ois.readObject(); }
flags.setProperties(props, false);
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
/** * Initialize this object using values in Properties object. The properties * are printed to stderr as it works. * * @param props The properties object used for initialization */ public final void setProperties(Properties props) { setProperties(props, true); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization * @param printProps Whether to print the properties on construction */ public SeqClassifierFlags(Properties props, boolean printProps) { setProperties(props, printProps); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public SeqClassifierFlags(Properties props) { setProperties(props, true); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public SeqClassifierFlags(Properties props) { setProperties(props, true); }
/** * Initialize this object using values in Properties object. The properties * are printed to stderr as it works. * * @param props * The properties object used for initialization */ public final void setProperties(Properties props) { setProperties(props, true); }
/** * Initialize this object using values in Properties object. * The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public final void setProperties(Properties props) { setProperties(props, true); } /**
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization * @param printProps Whether to print the properties on construction */ public SeqClassifierFlags(Properties props, boolean printProps) { setProperties(props, printProps); }
/** * Initialize this object using values in Properties object. The properties * are printed to stderr as it works. * * @param props The properties object used for initialization */ public final void setProperties(Properties props) { setProperties(props, true); }
/** * Create a new SeqClassifierFlags object and initialize it using values in * the Properties object. The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public SeqClassifierFlags(Properties props) { setProperties(props, true); }
/** Create a new SeqClassifierFlags object and initialize it * using values in the Properties object. * The properties are printed to stderr as it works. * * @param props The properties object used for initialization */ public SeqClassifierFlags(Properties props) { setProperties(props, true); }
/** Load a classifier from the given Stream. * <i>Implementation note: </i> This method <i>does not</i> close the * Stream that it reads from. * * @param ois The ObjectInputStream to load the serialized classifier from * * @throws IOException If there are problems accessing the input stream * @throws ClassCastException If there are problems interpreting the serialized data * @throws ClassNotFoundException If there are problems interpreting the serialized data * */ @SuppressWarnings("unchecked") @Override public void loadClassifier(ObjectInputStream ois, Properties props) throws ClassCastException, IOException, ClassNotFoundException { classifier = (LinearClassifier<String, String>) ois.readObject(); flags = (SeqClassifierFlags) ois.readObject(); featureFactory = (FeatureFactory) ois.readObject(); if (props != null) { flags.setProperties(props); } reinit(); classIndex = (Index<String>) ois.readObject(); answerArrays = (Set<List<String>>) ois.readObject(); knownLCWords = (Set<String>) ois.readObject(); }
/** Load a classifier from the given Stream. * <i>Implementation note: </i> This method <i>does not</i> close the * Stream that it reads from. * * @param ois The ObjectInputStream to load the serialized classifier from * * @throws IOException If there are problems accessing the input stream * @throws ClassCastException If there are problems interpreting the serialized data * @throws ClassNotFoundException If there are problems interpreting the serialized data * */ @SuppressWarnings("unchecked") @Override public void loadClassifier(ObjectInputStream ois, Properties props) throws ClassCastException, IOException, ClassNotFoundException { classifier = (LinearClassifier<String, String>) ois.readObject(); flags = (SeqClassifierFlags) ois.readObject(); Object featureFactory = ois.readObject(); if (featureFactory instanceof List) { featureFactories = ErasureUtils.uncheckedCast(featureFactory); } else if (featureFactory instanceof FeatureFactory) { featureFactories = Generics.newArrayList(); featureFactories.add((FeatureFactory) featureFactory); } if (props != null) { flags.setProperties(props); } reinit(); classIndex = (Index<String>) ois.readObject(); answerArrays = (Set<List<String>>) ois.readObject(); knownLCWords = (MaxSizeConcurrentHashSet<String>) ois.readObject(); }
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
@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