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

java.lang.Object
  extended by it.unimi.di.mg4j.search.score.AbstractAggregator
      extended by it.unimi.di.mg4j.search.score.LinearAggregator
All Implemented Interfaces:
Scorer, FlyweightPrototype<Scorer>

public class LinearAggregator
extends AbstractAggregator

An aggregator that computes a linear combination of the component scorers.

This class requires, beside the usually array of scorers, a parallel array of weights (not to be confused with index weights). The score from each scorer will be multiplied by the respective weight, and the overal score will be the sum of these values. Equalisation, if necessary, if performed by maximising over the sample scores and dividing all scores by the resulting value.


Field Summary
protected  double[] equalisationFactor
          The equalisation factors for each scorer (all set to one if no equalisation is required).
protected  double[] weight
          The weights of each scorer.
 
Fields inherited from class it.unimi.di.mg4j.search.score.AbstractAggregator
actualSamples, currSample, currScore, documentIterator, n, needsCaching, sampleDocument, samples, sampleScore, scorer
 
Constructor Summary
LinearAggregator(Scorer[] scorer, double[] weight)
          Creates a linear aggregator.
 
Method Summary
 LinearAggregator copy()
           
protected  double score(double[] score)
          Computes an aggregated score using the given array of basic scores.
protected  void setupEqualizationFactors()
          Sets up the equalisation factors.
 String toString()
           
 
Methods inherited from class it.unimi.di.mg4j.search.score.AbstractAggregator
equalize, getWeights, nextDocument, score, score, setWeights, usesIntervals, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

weight

protected final double[] weight
The weights of each scorer.


equalisationFactor

protected final double[] equalisationFactor
The equalisation factors for each scorer (all set to one if no equalisation is required).

Constructor Detail

LinearAggregator

public LinearAggregator(Scorer[] scorer,
                        double[] weight)
Creates a linear aggregator.

Parameters:
scorer - the array of scorers.
weight - the array of weights.
Method Detail

copy

public LinearAggregator copy()

score

protected double score(double[] score)
Description copied from class: AbstractAggregator
Computes an aggregated score using the given array of basic scores. The array is parallel to AbstractAggregator.scorer.

Specified by:
score in class AbstractAggregator
Parameters:
score - an array of scores.
Returns:
the aggregated scorer.

setupEqualizationFactors

protected void setupEqualizationFactors()
Description copied from class: AbstractAggregator
Sets up the equalisation factors.

Implementations should look into AbstractAggregator.sampleScore and set up the equalisation logic. Note that this method is responsible for setting up appropriate equalisation factors even if no equalisation is required (e.g., setting all factors to 1 ).

Specified by:
setupEqualizationFactors in class AbstractAggregator

toString

public String toString()
Overrides:
toString in class Object