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

java.lang.Object
  extended by it.unimi.dsi.fastutil.ints.AbstractIntIterator
      extended by it.unimi.dsi.mg4j.search.score.AbstractScorer
          extended by it.unimi.dsi.mg4j.search.score.DocumentRankScorer
All Implemented Interfaces:
IntIterator, FlyweightPrototype<Scorer>, DelegatingScorer, Scorer, Iterator<Integer>

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.dsi.mg4j.search.score.AbstractScorer
documentIterator
 
Constructor Summary
DocumentRankScorer(double[] score)
          Builds a document scorer with given scores.
DocumentRankScorer(String filename)
          Builds a document scorer by first reading the ranks from a file.
 
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.dsi.mg4j.search.score.AbstractScorer
hasNext, nextDocument, nextInt, setWeights, skip, wrap
 
Methods inherited from class it.unimi.dsi.fastutil.ints.AbstractIntIterator
next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.mg4j.search.score.Scorer
nextDocument, nextInt, setWeights, wrap
 
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterator
skip
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

DocumentRankScorer

public DocumentRankScorer(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

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