/** * Create a new recommender engine by reading a previously serialized engine from the * given file. The new engine will be identical to the old except it will use the new * DAOFactory. It is assumed that the file was created by using {@link #write(OutputStream)}. * Classes will be loaded using a default class loader. * * @param file The file from which to load the engine. * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. */ public static LenskitRecommenderEngine load(File file) throws IOException, RecommenderConfigurationException { return newLoader().load(file); }
/** * Create a new recommender engine by reading a previously serialized engine from the * given input stream. The new engine will be identical to the old. It is assumed that the file * was created by using {@link #write(OutputStream)}. Classes will be loaded using a default * class loader. * * @param input The stream from which to load the engine. * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. */ public static LenskitRecommenderEngine load(InputStream input) throws IOException, RecommenderConfigurationException { return newLoader().load(input); }
/** * Create a new recommender engine by reading a previously serialized engine from the * given file. The new engine will be identical to the old except it will use the new * DAOFactory. It is assumed that the file was created by using {@link #write(OutputStream)}. * * @param file The file from which to load the engine. * @param loader The class loader to load from ({@code null} to use a default class loader). * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. * @deprecated Use {@link LenskitRecommenderEngineLoader} for sophisticated loading. */ @Deprecated public static LenskitRecommenderEngine load(File file, ClassLoader loader) throws IOException, RecommenderConfigurationException { return newLoader().setClassLoader(loader).load(file); }
} else { logger.info("loading recommender from {}", modelFile); LenskitRecommenderEngineLoader loader = LenskitRecommenderEngine.newLoader(); loader.setClassLoader(environment.getClassLoader()); for (LenskitConfiguration config: environment.loadConfigurations(getConfigFiles())) {
/** * Load a configuration graph from a recommender model. * @param file The model file. * @return The recommender graph. * @throws IOException if there is an error loading the model. * @throws RecommenderConfigurationException if the model fails to configure. */ private DAGNode<Component, Dependency> loadModel(Context ctx, File file) throws IOException, RecommenderConfigurationException { logger.info("loading model from {}", file); LenskitRecommenderEngineLoader loader = LenskitRecommenderEngine.newLoader(); loader.setValidationMode(EngineValidationMode.DEFERRED) .addConfiguration(makeDataConfig(ctx)); for (LenskitConfiguration config: ctx.environment.loadConfigurations(ctx.getConfigFiles())) { loader.addConfiguration(config); } LenskitRecommenderEngine engine = loader.load(file); return engine.getGraph(); }
/** * Create a new recommender engine by reading a previously serialized engine from the * given file. The new engine will be identical to the old except it will use the new * DAOFactory. It is assumed that the file was created by using {@link #write(OutputStream)}. * Classes will be loaded using a default class loader. * * @param file The file from which to load the engine. * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. */ public static LenskitRecommenderEngine load(File file) throws IOException, RecommenderConfigurationException { return newLoader().load(file); }
/** * Create a new recommender engine by reading a previously serialized engine from the * given input stream. The new engine will be identical to the old. It is assumed that the file * was created by using {@link #write(OutputStream)}. Classes will be loaded using a default * class loader. * * @param input The stream from which to load the engine. * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. */ public static LenskitRecommenderEngine load(InputStream input) throws IOException, RecommenderConfigurationException { return newLoader().load(input); }
/** * Create a new recommender engine by reading a previously serialized engine from the * given file. The new engine will be identical to the old except it will use the new * DAOFactory. It is assumed that the file was created by using {@link #write(OutputStream)}. * * @param file The file from which to load the engine. * @param loader The class loader to load from ({@code null} to use a default class loader). * @return The loaded recommender engine. * @throws IOException If there is an error reading from the file. * @throws RecommenderConfigurationException * If the configuration cannot be used. * @deprecated Use {@link LenskitRecommenderEngineLoader} for sophisticated loading. */ @Deprecated public static LenskitRecommenderEngine load(File file, ClassLoader loader) throws IOException, RecommenderConfigurationException { return newLoader().setClassLoader(loader).load(file); }