Class AbstractWeightedScorer
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.score.AbstractScorer
-
- it.unimi.di.big.mg4j.search.score.AbstractWeightedScorer
-
- All Implemented Interfaces:
Scorer,FlyweightPrototype<Scorer>
- Direct Known Subclasses:
BM25FScorer,BM25Scorer,ClarkeCormackScorer,CountScorer,TfIdfScorer,VignaScorer
public abstract class AbstractWeightedScorer extends AbstractScorer
An abstract subsclass ofAbstractScorerproviding internal storage and copy of the weight map and a default implementation ofscore().Warning: implementing subclasses must implement
Scorer.copy()so that the state of the weight map is replicated, too.
-
-
Field Summary
Fields Modifier and Type Field Description protected Reference2DoubleOpenHashMap<Index>index2WeightA map associating a weight with each index.-
Fields inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
documentIterator, indexIterator
-
-
Constructor Summary
Constructors Constructor Description AbstractWeightedScorer()
-
Method Summary
Modifier and Type Method Description Reference2DoubleMap<Index>getWeights()Returns an empty map.doublescore()Computes a score by callingScorer.score(Index)for each index in the current document iterator, and adding the weighted results.booleansetWeights(Reference2DoubleMap<Index> index2Weight)Copies the argument internally, rescaling weights so they sum up to one.voidwrap(DocumentIterator documentIterator)Wraps the given document iterator.-
Methods inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
nextDocument
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.score.Scorer
copy, score, usesIntervals
-
-
-
-
Field Detail
-
index2Weight
protected Reference2DoubleOpenHashMap<Index> index2Weight
A map associating a weight with each index.
-
-
Method Detail
-
setWeights
public boolean setWeights(Reference2DoubleMap<Index> index2Weight)
Copies the argument internally, rescaling weights so they sum up to one.- Specified by:
setWeightsin interfaceScorer- Overrides:
setWeightsin classAbstractScorer- Parameters:
index2Weight- the new map from indices to weights.- Returns:
- true.
-
getWeights
public final Reference2DoubleMap<Index> getWeights()
Description copied from class:AbstractScorerReturns an empty map.- Specified by:
getWeightsin interfaceScorer- Overrides:
getWeightsin classAbstractScorer- Returns:
- a copy of the weight map of this scorer.
-
score
public double score() throws IOExceptionComputes a score by callingScorer.score(Index)for each index in the current document iterator, and adding the weighted results.- Returns:
- the combined weighted score.
- Throws:
IOException
-
wrap
public void wrap(DocumentIterator documentIterator) throws IOException
Description copied from class:AbstractScorerWraps the given document iterator.This method records internally the provided iterator.
- Specified by:
wrapin interfaceScorer- Overrides:
wrapin classAbstractScorer- Parameters:
documentIterator- the document iterator that will be used in subsequent calls toScorer.score()andScorer.score(Index).- Throws:
IOException
-
-