Class DecreasingDocumentRankScorer
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.score.AbstractScorer
-
- it.unimi.di.big.mg4j.search.score.DecreasingDocumentRankScorer
-
- All Implemented Interfaces:
DelegatingScorer,Scorer,FlyweightPrototype<Scorer>
public class DecreasingDocumentRankScorer extends AbstractScorer implements DelegatingScorer
Compute scores that do not depend on intervals, but that just assign a fixed score to each document starting from 1; scores are read from a file whose name is passed to the constructor.This scorer assumes that scores are nonnegative and that documents are ordered in decreasing score order: that is, that if i < j then the score of i is greater than or equal to the score of j. This allows to normalise the score (the document with the highest score has exactly score 1) without additional costs. This scorer will throw an
IllegalStateExceptionif this assumption is violated.Warning: this scorer assumes that there are no more than
Integer.MAX_VALUEdocuments.
-
-
Field Summary
-
Fields inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
documentIterator, indexIterator
-
-
Constructor Summary
Constructors Constructor Description DecreasingDocumentRankScorer(double[] score)Builds a document scorer with given scores.DecreasingDocumentRankScorer(String filename)Builds a document scorer by first reading the ranks from a file.
-
Method Summary
Modifier and Type Method Description DecreasingDocumentRankScorercopy()doublescore()Returns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator).doublescore(Index index)Returns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator), but considering only a given index (optional operation).StringtoString()booleanusesIntervals()Whether this scorer uses intervals.voidwrap(DocumentIterator documentIterator)Wraps the given document iterator.-
Methods inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
getWeights, nextDocument, setWeights
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unimi.di.big.mg4j.search.score.Scorer
getWeights, nextDocument, setWeights
-
-
-
-
Constructor Detail
-
DecreasingDocumentRankScorer
public DecreasingDocumentRankScorer(String filename) throws IOException
Builds a document scorer by first reading the ranks from a file. Ranks are saved as doubles (the first double is the rank of document 0 and so on).- Parameters:
filename- the name of the rank file.- Throws:
IOException
-
DecreasingDocumentRankScorer
public DecreasingDocumentRankScorer(double[] score)
Builds a document scorer with given scores.- Parameters:
score- the scores (they are not copied, so the caller is supposed not to change their values).
-
-
Method Detail
-
copy
public DecreasingDocumentRankScorer copy()
- Specified by:
copyin interfaceFlyweightPrototype<Scorer>- Specified by:
copyin interfaceScorer
-
score
public double score()
Description copied from interface:ScorerReturns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator).
-
score
public double score(Index index)
Description copied from interface:ScorerReturns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator), but considering only a given index (optional operation).
-
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
-
usesIntervals
public boolean usesIntervals()
Description copied from interface:ScorerWhether this scorer uses intervals.This method is essential when aggregating scorers, because if several scores need intervals, a
CachingDocumentIteratorwill be necessary.- Specified by:
usesIntervalsin interfaceScorer- Returns:
- true if this scorer uses intervals.
-
-