public class DFRSimilarity extends SimilarityBaseImplements the divergence from randomness (DFR) framework introduced in Gianni Amati and Cornelis Joost Van Rijsbergen. 2002. Probabilistic models of information retrieval based on measuring the divergence from randomness. ACM Trans. Inf. Syst. 20, 4 (October 2002), 357-389.
The DFR scoring formula is composed of three separate components: the basic model, the aftereffect and an additional normalization component, represented by the classes
Normalization, respectively. The names of these classes were chosen to match the names of their counterparts in the Terrier IR engine.
To construct a DFRSimilarity, you must specify the implementations for all three components of DFR:
BasicModel: Basic model of information content:
BasicModelBE: Limiting form of Bose-Einstein
BasicModelG: Geometric approximation of Bose-Einstein
BasicModelP: Poisson approximation of the Binomial
BasicModelD: Divergence approximation of the Binomial
BasicModelIn: Inverse document frequency
BasicModelIne: Inverse expected document frequency [mixture of Poisson and IDF]
BasicModelIF: Inverse term frequency [approximation of I(ne)]
AfterEffect: First normalization of information gain:
Normalization: Second (length) normalization:
NormalizationH1: Uniform distribution of term frequency
NormalizationH2: term frequency density inversely related to length
NormalizationH3: term frequency normalization provided by Dirichlet prior
NormalizationZ: term frequency normalization provided by a Zipfian relation
Normalization.NoNormalization: no second normalization
Note that qtf, the multiplicity of term-occurrence in the query, is not handled by this implementation.
Fields Modifier and Type Field Description
afterEffectThe first normalization of the information content.
basicModelThe basic model for information content.
normalizationThe term frequency normalization.
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
explain(List<Explanation> subs, BasicStats stats, int doc, float freq, float docLen)Subclasses should implement this method to explain the score.
getAfterEffect()Returns the first normalization
getBasicModel()Returns the basic model of information content
getNormalization()Returns the second normalization
score(BasicStats stats, float freq, float docLen)Scores the document
toString()Subclasses must override this method to return the name of the Similarity and preferably the values of parameters (if any) as well.
Methods inherited from class org.apache.lucene.search.similarities.SimilarityBase
computeNorm, computeWeight, explain, fillBasicStats, getDiscountOverlaps, log2, newStats, setDiscountOverlaps, simScorer
public DFRSimilarity(BasicModel basicModel, AfterEffect afterEffect, Normalization normalization)Creates DFRSimilarity from the three components.
basicModel- Basic model of information content
afterEffect- First normalization of information gain
normalization- Second (length) normalization
protected float score(BasicStats stats, float freq, float docLen)Scores the document
Subclasses must apply their scoring formula in this class.
protected void explain(List<Explanation> subs, BasicStats stats, int doc, float freq, float docLen)Subclasses should implement this method to explain the score.
explalready contains the score, the name of the class and the doc id, as well as the term frequency and its explanation; subclasses can add additional clauses to explain details of their scoring formulae.
The default implementation does nothing.
public String toString()Subclasses must override this method to return the name of the Similarity and preferably the values of parameters (if any) as well.
public BasicModel getBasicModel()Returns the basic model of information content
public AfterEffect getAfterEffect()Returns the first normalization
public Normalization getNormalization()Returns the second normalization