public class DFRSimilarity extends SimilarityBase
The DFR scoring formula is composed of three separate components: the
basic model, the aftereffect and an additional
normalization component, represented by the classes
BasicModel
, AfterEffect
and 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:
BasicModelG
: Geometric approximation of Bose-Einstein
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:
AfterEffectL
: Laplace's law of succession
AfterEffectB
: Ratio of two Bernoulli processes
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.
Note that basic models BE (Limiting form of Bose-Einstein), P (Poisson approximation of the Binomial) and D (Divergence approximation of the Binomial) are not implemented because their formula couldn't be written in a way that makes scores non-decreasing with the normalized term frequency.
BasicModel
,
AfterEffect
,
Normalization
Similarity.SimScorer
Modifier and Type | Field and Description |
---|---|
protected AfterEffect |
afterEffect
The first normalization of the information content.
|
protected BasicModel |
basicModel
The basic model for information content.
|
protected Normalization |
normalization
The term frequency normalization.
|
discountOverlaps
Constructor and Description |
---|
DFRSimilarity(BasicModel basicModel,
AfterEffect afterEffect,
Normalization normalization)
Creates DFRSimilarity from the three components.
|
Modifier and Type | Method and Description |
---|---|
protected Explanation |
explain(BasicStats stats,
Explanation freq,
double docLen)
Explains the score.
|
protected void |
explain(List<Explanation> subs,
BasicStats stats,
double freq,
double docLen)
Subclasses should implement this method to explain the score.
|
AfterEffect |
getAfterEffect()
Returns the first normalization
|
BasicModel |
getBasicModel()
Returns the basic model of information content
|
Normalization |
getNormalization()
Returns the second normalization
|
protected double |
score(BasicStats stats,
double freq,
double docLen)
Scores the document
doc . |
String |
toString()
Subclasses must override this method to return the name of the Similarity
and preferably the values of parameters (if any) as well.
|
computeNorm, fillBasicStats, getDiscountOverlaps, log2, newStats, scorer, setDiscountOverlaps
protected final BasicModel basicModel
protected final AfterEffect afterEffect
protected final Normalization normalization
public DFRSimilarity(BasicModel basicModel, AfterEffect afterEffect, Normalization normalization)
Note that null
values are not allowed:
if you want no normalization, instead pass
Normalization.NoNormalization
.
basicModel
- Basic model of information contentafterEffect
- First normalization of information gainnormalization
- Second (length) normalizationprotected double score(BasicStats stats, double freq, double docLen)
SimilarityBase
doc
.
Subclasses must apply their scoring formula in this class.
score
in class SimilarityBase
stats
- the corpus level statistics.freq
- the term frequency.docLen
- the document length.protected void explain(List<Explanation> subs, BasicStats stats, double freq, double docLen)
SimilarityBase
expl
already 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.
explain
in class SimilarityBase
subs
- the list of details of the explanation to extendstats
- the corpus level statistics.freq
- the term frequency.docLen
- the document length.protected Explanation explain(BasicStats stats, Explanation freq, double docLen)
SimilarityBase
SimilarityBase.score(BasicStats, double, double)
method) and the explanation for the term frequency. Subclasses content with
this format may add additional details in
SimilarityBase.explain(List, BasicStats, double, double)
.explain
in class SimilarityBase
stats
- the corpus level statistics.freq
- the term frequency and its explanation.docLen
- the document length.public String toString()
SimilarityBase
toString
in class SimilarityBase
public BasicModel getBasicModel()
public AfterEffect getAfterEffect()
public Normalization getNormalization()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.