/** * Create a node processor that will instantiate nodes. It will return nodes whose satisfactions * have been replaced with instance satisfactions containing the instance. * * @return The node processor. */ public static NodeProcessor instantiate() { return instantiate(NodeInstantiator.create()); }
/** * Item scorer that scores every item with the global mean rating. It is not useful to use this scorer for * ranking items. */ @Shareable public class GlobalMeanRatingItemScorer extends ConstantItemScorer { private static final long serialVersionUID = 1L; @Inject public GlobalMeanRatingItemScorer(@Transient RatingSummary summary) { super(summary.getGlobalMean()); } }
/** * Instantiate the recommender graph. * @param graph The recommender graph. * @return The instantiated graph. */ protected DAGNode<Component, Dependency> instantiateGraph(DAGNode<Component, Dependency> graph) { RecommenderInstantiator inst = RecommenderInstantiator.create(graph); graph = inst.instantiate(); return graph; }
public <T> T tryGetInstance(QualifierMatcher qmatch, Class<T> type) throws InjectionException { DAGNode<Component, Dependency> node = GraphtUtils.findSatisfyingNode(graph, qmatch, type); return node != null ? type.cast(instantiator.instantiate(node)) : null; }
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { checkShareableComponents(roundEnv); checkParameters(roundEnv); return false; }
/** * Simulate instantiating a graph. * @return The simulated graph. */ public DAGNode<Component,Dependency> simulate() throws RecommenderBuildException { try { return replaceShareableNodes(NodeProcessors.simulateInstantiation()); } catch (InjectionException e) { throw new RecommenderBuildException("Simulated instantiation failed", e); } }
/** * Create a new LensKit recommender. Most code does not need to call this constructor, but * rather use {@link #build(LenskitConfiguration)} or a {@link LenskitRecommenderEngine}. * * @param graph This recommender's configuration graph. */ public LenskitRecommender(DAGNode<Component, Dependency> graph) { injector = new StaticInjector(graph); }
/** * Build a dependency 'unsolver' from the provided bindings. The resulting solver, when rewriting * a graph, will replace bound targets with placeholders. * @return The dependency solver. */ public DependencySolver buildDependencyUnsolver() { return buildDependencySolverImpl(SolveDirection.UNSOLVE); }
/** * Create a node processor that will instantiate nodes. It will return nodes whose satisfactions * have been replaced with instance satisfactions containing the instance. * * @param inst The node instantiator to use when instantiating nodes. * @return The node processor. */ public static NodeProcessor instantiate(NodeInstantiator inst) { return new InstantiatingNodeProcessor(inst); }
/** * Create a node processor that will simulate instantiating nodes. * @return The node processor. */ public static NodeProcessor simulateInstantiation() { return new SimulationNodeProcessor(); }
/** * Wrap a binding in a LensKit binding. * @param binding The binding to wrap. * @param <T> The bound type. * @return The LensKit binding wrapper. */ static <T> LenskitBinding<T> wrap(Binding<T> binding) { return wrap(binding, null); }
/** * Create a node instantiator without a lifecycle manager. * @return A node instantiator that does not support lifecycle management. */ public static NodeInstantiator create() { return new DefaultImpl(null); }
@Override public void close() { injector.close(); }
/** * Coerce a Grapht context to a LensKit context. * * @param ctx The context. * @return A LensKit context, as a wrapper if necessary. */ protected static LenskitConfigContext wrapContext(Context ctx) { if (ctx instanceof LenskitConfigContext) { return (LenskitConfigContext) ctx; } else { return new ContextWrapper(ctx); } }
private Object writeReplace() { return new SerialProxy(removedType); }
/** * A {@code VectorTruncator} that does not actually perform any truncation. * Any input vector is returned unchanged. */ @Shareable public class NoOpTruncator implements VectorTruncator, Serializable { private static final long serialVersionUID = 1L; @Override public Long2DoubleMap truncate(Long2DoubleMap v) { return LongUtils.frozenMap(v); } }
/** * Build a dependency solver from the provided bindings. * * @return The dependency solver. */ public DependencySolver buildDependencySolver() { return buildDependencySolverImpl(SolveDirection.SOLVE); }
/** * Represents the absence of a threshold function, choosing * to retain all similarity values passed to it. */ @Shareable public class NoThreshold implements Threshold, Serializable { private static final long serialVersionUID = 1; @Override public boolean retain(double sim) { return true; } }
/** * Identity clamping function. * * @author <a href="http://www.grouplens.org">GroupLens Research</a> * @since 0.11 */ @Shareable public final class IdentityClampingFunction implements ClampingFunction, Serializable { private static final long serialVersionUID = 1L; @Override public double apply(long user, long item, double value) { return value; } }