/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon) from the given file. In that file, there should first be * stored a string containing the fully qualified class name of the learner. If the <i>short</i> * value <code>-1</code> appears instead, this method returns <code>null</code>. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param filename The name of the file from which to read the learner. * @return The learner read from the file. **/ public static Learner readLearner(String filename) { return readLearner(filename, true); }
/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon) from the given stream. The stream is expected to first return * a string containing the fully qualified class name of the learner. If the <i>short</i> value * <code>-1</code> appears instead, this method returns <code>null</code>. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param in The input stream. * @return The learner read from the stream. **/ public static Learner readLearner(ExceptionlessInputStream in) { return readLearner(in, true); }
/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon) from the given location. At that location, there should first * be stored a string containing the fully qualified class name of the learner. If the * <i>short</i> value <code>-1</code> appears instead, this method returns <code>null</code>. * Finally, the location is cached in {@link #lcFilePath}. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param url The location from which to read the learner. * @return The learner read from the location. **/ public static Learner readLearner(URL url) { return readLearner(url, true); }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException( "Can't locate QuantitiesClassifier.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException( "Can't locate QuantitiesClassifier.lc in the class path."); } instance = (QuantitiesClassifier) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException( "Can't locate QuantitiesClassifier.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException( "Can't locate QuantitiesClassifier.lc in the class path."); } instance = (QuantitiesClassifier) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate QuestionCoarseTyper.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate QuestionCoarseTyper.lc in the class path."); } instance = (QuestionCoarseTyper) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon), with the option of cutting off the reading process after the * label lexicon and before any learned parameters. When <code>whole</code> is * <code>false</code>, the reading process is cut off in this way. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param filename The name of the file from which to read the learner. * @param whole Whether or not to read the whole model. * @return The learner read from the file. **/ public static Learner readLearner(String filename, boolean whole) { URL url = null; try { url = new URL("file:" + filename); } catch (Exception e) { System.err.println("Error constructing URL:"); e.printStackTrace(); System.exit(1); } return readLearner(url, whole); }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } instance = (NETaggerLevel1) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate QuestionCoarseTyper.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate QuestionCoarseTyper.lc in the class path."); } instance = (QuestionCoarseTyper) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } instance = (NETaggerLevel2) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } instance = (NETaggerLevel1) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate QuestionFineTyper.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate QuestionFineTyper.lc in the class path."); } instance = (QuestionFineTyper) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } instance = (NETaggerLevel2) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel2.lc in the class path."); } instance = (NETaggerLevel2) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate QuestionFineTyper.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate QuestionFineTyper.lc in the class path."); } instance = (QuestionFineTyper) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
private static void loadInstance() { if (instance == null) { if (_lcFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } if (_lexFilePath == null) { throw new RuntimeException("Can't locate NETaggerLevel1.lc in the class path."); } instance = (NETaggerLevel1) Learner.readLearner(_lcFilePath); instance.readLexiconOnDemand(_lexFilePath); } }
/** * Reads the binary representation of any type of learner (including the label lexicon, but not * including the feature lexicon), with the option of cutting off the reading process after the * label lexicon and before any learned parameters. When <code>whole</code> is * <code>false</code>, the reading process is cut off in this way. Finally, the location is * cached in {@link #lcFilePath}. * * <p> * This method is appropriate for reading learners as written by * {@link #write(ExceptionlessOutputStream)}. * * @param url The location from which to read the learner. * @param whole Whether or not to read the whole model. * @return The learner read from the location. **/ public static Learner readLearner(URL url, boolean whole) { ExceptionlessInputStream in = ExceptionlessInputStream.openCompressedStream(url); Learner result = readLearner(in, whole); in.close(); result.lcFilePath = url; return result; }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); baseLTU = (LinearThresholdUnit) Learner.readLearner(in); conjunctiveLabels = in.readBoolean(); int N = in.readInt(); network = new OVector(N); for (int i = 0; i < N; ++i) network.add(Learner.readLearner(in)); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); weakLearner = Learner.readLearner(in); rounds = in.readInt(); for (int i = 0; i < rounds; ++i) weakLearners[i] = Learner.readLearner(in); for (int i = 0; i < rounds; ++i) alpha[i] = in.readDouble(); allowableValues = new String[2]; allowableValues[0] = in.readString(); allowableValues[1] = in.readString(); }
/** * Reads the binary representation of a learner with this object's run-time type, overwriting * any and all learned or manually specified parameters as well as the label lexicon but without * modifying the feature lexicon. * * @param in The input stream. **/ public void read(ExceptionlessInputStream in) { super.read(in); defaultPrediction = in.readString(); setDefaultFeature(); baseLearner = Learner.readLearner(in); int N = in.readInt(); network = new OVector(N); int M = in.readInt(); for (int i = 0; i < M; ++i) network.set(in.readInt(), Learner.readLearner(in)); }