it.unimi.dsi.mg4j.search.score
Class AbstractWeightedScorer
java.lang.Object
it.unimi.dsi.fastutil.ints.AbstractIntIterator
it.unimi.dsi.mg4j.search.score.AbstractScorer
it.unimi.dsi.mg4j.search.score.AbstractIndexScorer
it.unimi.dsi.mg4j.search.score.AbstractWeightedScorer
- All Implemented Interfaces:
- IntIterator, FlyweightPrototype<Scorer>, Scorer, Iterator<Integer>
- Direct Known Subclasses:
- BM25Scorer, ClarkeCormackScorer, CountScorer, TfIdfScorer, VignaScorer
public abstract class AbstractWeightedScorer
- extends AbstractIndexScorer
An abstract subsclass of AbstractIndexScorer
providing internal storage and copy of the weight map, faster array-based
access to the latter, and a default implementation of score()
.
Warning: implementing subclasses must implement
Scorer.copy()
so that the state of the
weight map is replicated, too.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
index2Weight
protected Reference2DoubleOpenHashMap<Index> index2Weight
- A map associating a weight with each index.
currWeight
protected double[] currWeight
- An array parallel to
AbstractIndexScorer.currIndex
containing the current corresponding values in index2Weight
;
it is set up by wrap(DocumentIterator)
.
AbstractWeightedScorer
public AbstractWeightedScorer()
setWeights
public boolean setWeights(Reference2DoubleMap<Index> index2Weight)
- Copies the argument internally, rescaling weights so they sum up to one.
- Specified by:
setWeights
in interface Scorer
- Overrides:
setWeights
in class AbstractScorer
- Parameters:
index2Weight
- the new map from indices to weights.
- Returns:
- true.
score
public double score()
throws IOException
- Computes a score by calling
Scorer.score(Index)
for
each index in the current index map, and summing the weighted results.
- Returns:
- the combined weighted score.
- Throws:
IOException
wrap
public void wrap(DocumentIterator documentIterator)
throws IOException
- Wraps the given document iterator.
Besides the services provided by AbstractIndexScorer.wrap(DocumentIterator)
,
this method sets up currWeight
.
- Specified by:
wrap
in interface Scorer
- Overrides:
wrap
in class AbstractIndexScorer
- Parameters:
documentIterator
- the document iterator that will be used in subsequent calls to
score()
and Scorer.score(Index)
.
- Throws:
IOException