/** * Construct a recommender with some additional configuration. This can be used to do things * like add data source configuration on a per-recommender, rather than per-engine, basis. * * @param config The configuration to adjust the recommender. * @return The constructed recommender. * @throws RecommenderConfigurationException if there is an error configuring the recommender. */ public LenskitRecommender createRecommender(LenskitConfiguration config) throws RecommenderConfigurationException { final DAGNode<Component, Dependency> toBuild = createRecommenderGraph(config); return new LenskitRecommender(toBuild); }
/** * Build a LensKit recommender engine from a configuration. The resulting recommender is * independent of any subsequent modifications to the configuration. * * @param config The configuration. * @param dao The data access object * @return The recommender engine. */ public static LenskitRecommenderEngine build(LenskitConfiguration config, DataAccessObject dao) throws RecommenderBuildException { return newBuilder().addConfiguration(config).build(dao); }
protected LenskitConfiguration getDaoConfig() { LenskitConfiguration config = new LenskitConfiguration(); config.bind(DataAccessObject.class) .toProvider(source); return config; }
/** * Create a LensKit recommender. * @param dao The data access object * @return The constructed recommender. */ public LenskitRecommender createRecommender(@WillNotClose DataAccessObject dao) throws RecommenderBuildException { LenskitConfiguration config = new LenskitConfiguration(); config.addComponent(dao); return createRecommender(config); }
/** * Construct a new delegate with an empty configuration. * * @param loader The configuration loader * @param base The base URL */ public LenskitConfigDSL(ConfigurationLoader loader, URI base) { this(loader, new LenskitConfiguration(), base); }
/** * Build the recommender directly, skipping an engine. This does not separate the recommender from * the DAO, it just directly builds it. * * @param dao The data access object to use. Can be `null` to build without a DAO, but this is only useful in * special cases. * @return The built recommender engine, with {@linkplain ModelDisposition#EXCLUDED excluded} * components removed. * @throws RecommenderBuildException if there is an error building the engine. */ public LenskitRecommender buildRecommender(DataAccessObject dao) throws RecommenderBuildException { DAGNode<Component, Dependency> graph = buildRecommenderGraph(dao); graph = instantiateGraph(graph); return new LenskitRecommender(graph); }
@Override public ItemRecommender getItemRecommender() { return get(ItemRecommender.class); }
/** @see LenskitConfigContext#bind(Class) */ @Override public <T> LenskitBinding<T> bind(Class<T> type) { return context.bind(type); }
/** * 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); }
/** * Add a configuration to be included in the recommender engine. This is the equivalent of * calling {@link #addConfiguration(LenskitConfiguration, ModelDisposition)} with the {@link ModelDisposition#INCLUDED}. * @param config The configuration. * @return The builder (for chaining). */ public LenskitRecommenderEngineBuilder addConfiguration(LenskitConfiguration config) { return addConfiguration(config, ModelDisposition.INCLUDED); }
/** * Add a root type. * @param type The type to add. * @see LenskitConfiguration#addRoot(Class) */ public void root(Class<?> type) { config.addRoot(type); }
/** @see LenskitConfigContext#within(Class) */ @Override public LenskitConfigContext within(Class<?> type) { return context.within(type); }
/** * Create a new recommender engine builder. * @return A new recommender engine builder. */ public static LenskitRecommenderEngineBuilder newBuilder() { return new LenskitRecommenderEngineBuilder(); }
/** * Create a new recommender engine loader. * @return A new recommender engine loader. */ public static LenskitRecommenderEngineLoader newLoader() { return new LenskitRecommenderEngineLoader(); } }
/** @see LenskitConfigContext#bindAny(Class) */ @Override public <T> LenskitBinding<T> bindAny(Class<T> type) { return context.bindAny(type); }
/** @see LenskitConfigContext#at(Class) */ @Override public LenskitConfigContext at(Class<?> type) { return context.at(type); }
/** * Build a LensKit recommender engine from a configuration. The resulting recommender is * independent of any subsequent modifications to the configuration. * * @param config The configuration. * @return The recommender engine. */ @SuppressWarnings("deprecation") public static LenskitRecommenderEngine build(LenskitConfiguration config) throws RecommenderBuildException { return newBuilder().addConfiguration(config).build(); }
/** * Convenience method to copy a LensKit configuration. * @return An independent copy of this configuration. */ public LenskitConfiguration copy() { return new LenskitConfiguration(this); }
/** @see LenskitConfigContext#bind(Class, Class) */ @Override public <T> LenskitBinding<T> bind(Class<? extends Annotation> qual, Class<T> type) { return context.bind(qual, type); }
/** * 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); }