Class DocumentRankScorer
- java.lang.Object
-
- it.unimi.di.big.mg4j.search.score.AbstractScorer
-
- it.unimi.di.big.mg4j.search.score.DocumentRankScorer
-
- All Implemented Interfaces:
DelegatingScorer
,Scorer
,FlyweightPrototype<Scorer>
public class DocumentRankScorer extends AbstractScorer implements DelegatingScorer
Compute scores that do not depend on intervals, but that just assign a fixed score to each document; scores are read from a file whose name is passed to the constructor.
-
-
Field Summary
-
Fields inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
documentIterator, indexIterator
-
-
Constructor Summary
Constructors Constructor Description DocumentRankScorer(double[][] score)
Builds a document scorer with given scores.DocumentRankScorer(String filename)
Builds a document scorer by reading the ranks from a file.DocumentRankScorer(String filename, String type)
Builds a document scorer by reading the ranks from a file of specified type.DocumentRankScorer(String filename, String type, boolean gzip)
Builds a document scorer by reading the ranks from a file of specified type.DocumentRankScorer(String filename, String type, String gzip)
Builds a document scorer by reading the ranks from a file of specified type.
-
Method Summary
Modifier and Type Method Description DocumentRankScorer
copy()
double
score()
Returns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator)
.double
score(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).String
toString()
boolean
usesIntervals()
Whether this scorer uses intervals.-
Methods inherited from class it.unimi.di.big.mg4j.search.score.AbstractScorer
getWeights, nextDocument, setWeights, wrap
-
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, wrap
-
-
-
-
Constructor Detail
-
DocumentRankScorer
public DocumentRankScorer(String filename) throws IOException
Builds a document scorer by reading the ranks from a file. Ranks are saved as doubles (the first double is the rank of document 0 and so on).This constructor can be used with an
ObjectParser
.- Parameters:
filename
- the name of the rank file.- Throws:
IOException
-
DocumentRankScorer
public DocumentRankScorer(String filename, String type, String gzip) throws IOException
Builds a document scorer by reading the ranks from a file of specified type.This constructor has the same arguments as
DocumentRankScorer(String, String, boolean)
, but it can be used with anObjectParser
.- Parameters:
filename
- the name of the rank file.type
- one of int, long, float or double.gzip
- a boolean specifying whether the file is gzip'd.- Throws:
IOException
- See Also:
DocumentRankScorer(String)
-
DocumentRankScorer
public DocumentRankScorer(String filename, String type) throws IOException
Builds a document scorer by reading the ranks from a file of specified type.This constructor can be used with an
ObjectParser
.- Parameters:
filename
- the name of the rank file.type
- one of int, long, float or double.- Throws:
IOException
- See Also:
DocumentRankScorer(String)
-
DocumentRankScorer
public DocumentRankScorer(String filename, String type, boolean gzip) throws IOException
Builds a document scorer by reading the ranks from a file of specified type.- Parameters:
filename
- the name of the rank file.type
- one of int, long, float or double.gzip
- whether the file is gzip'd.- Throws:
IOException
- See Also:
DocumentRankScorer(String)
-
DocumentRankScorer
public DocumentRankScorer(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 DocumentRankScorer copy()
- Specified by:
copy
in interfaceFlyweightPrototype<Scorer>
- Specified by:
copy
in interfaceScorer
-
score
public double score()
Description copied from interface:Scorer
Returns 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:Scorer
Returns a score for the current document of the last document iterator given toScorer.wrap(DocumentIterator)
, but considering only a given index (optional operation).
-
usesIntervals
public boolean usesIntervals()
Description copied from interface:Scorer
Whether this scorer uses intervals.This method is essential when aggregating scorers, because if several scores need intervals, a
CachingDocumentIterator
will be necessary.- Specified by:
usesIntervals
in interfaceScorer
- Returns:
- true if this scorer uses intervals.
-
-