public class FallbackItemScorer extends AbstractItemScorer
Item scorer that combines a primary scorer with a baseline. This scorer is comprised of two other scorers, a primary scorer and a baseline scorer. It first scores items using the primary scorer, and then consults the baseline scorer for any items that the primary scorer could not score.
Modifier and Type | Class and Description |
---|---|
static class |
FallbackItemScorer.DynamicProvider
An item scorer provider for opportunistically creating fallback scorers.
|
Constructor and Description |
---|
FallbackItemScorer(ItemScorer primary,
ItemScorer baseline) |
Modifier and Type | Method and Description |
---|---|
ItemScorer |
getBaselineScorer()
Get the baseline scorer from this item scorer.
|
ItemScorer |
getPrimaryScorer()
Get the primary scorer from this item scorer.
|
FallbackResult |
score(long user,
long item)
Score a single item.
|
ResultMap |
scoreWithDetails(long user,
java.util.Collection<java.lang.Long> items)
Score a collection of items and potentially return more details on the scores.
|
score
@Inject public FallbackItemScorer(@PrimaryScorer ItemScorer primary, @BaselineScorer ItemScorer baseline)
public FallbackResult score(long user, long item)
AbstractItemScorer
Score a single item.
This implementation delegates to ItemScorer.scoreWithDetails(long, Collection)
.
score
in interface ItemScorer
score
in class AbstractItemScorer
user
- The user ID for whom to generate a score.item
- The item ID to score.null
if no score can be generated.@Nonnull public ResultMap scoreWithDetails(long user, @Nonnull java.util.Collection<java.lang.Long> items)
ItemScorer
Score a collection of items and potentially return more details on the scores.
user
- The user ID for whom to generate scores.items
- The item to score.ResultMap
that provides access to those details.@Nonnull public ItemScorer getPrimaryScorer()
Get the primary scorer from this item scorer.
PrimaryScorer
@Nonnull public ItemScorer getBaselineScorer()
Get the baseline scorer from this item scorer.
BaselineScorer