it.unimi.di.mg4j.search.score
Class DocumentRankScorer

java.lang.Object
  extended by it.unimi.di.mg4j.search.score.AbstractScorer
      extended by it.unimi.di.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.mg4j.search.score.AbstractScorer
documentIterator, indexIterator
 
Constructor Summary
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
 DocumentRankScorer copy()
           
 double score()
          Returns a score for the current document of the last document iterator given to Scorer.wrap(DocumentIterator).
 double score(Index index)
          Returns a score for the current document of the last document iterator given to Scorer.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.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.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 an ObjectParser.

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 interface DelegatingScorer
Specified by:
copy in interface Scorer
Specified by:
copy in interface FlyweightPrototype<Scorer>

score

public double score()
Description copied from interface: Scorer
Returns a score for the current document of the last document iterator given to Scorer.wrap(DocumentIterator).

Specified by:
score in interface Scorer
Returns:
the score.

score

public double score(Index index)
Description copied from interface: Scorer
Returns a score for the current document of the last document iterator given to Scorer.wrap(DocumentIterator), but considering only a given index (optional operation).

Specified by:
score in interface Scorer
Parameters:
index - the only index to be considered.
Returns:
the score.

toString

public String toString()
Overrides:
toString in class Object

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 interface Scorer
Returns:
true if this scorer uses intervals.