Class DFRSimilarity
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:BasicModelBE
: Limiting form of Bose-EinsteinBasicModelG
: Geometric approximation of Bose-EinsteinBasicModelP
: Poisson approximation of the BinomialBasicModelD
: Divergence approximation of the BinomialBasicModelIn
: Inverse document frequencyBasicModelIne
: 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 successionAfterEffectB
: Ratio of two Bernoulli processesAfterEffect.NoAfterEffect
: no first normalization
Normalization
: Second (length) normalization:NormalizationH1
: Uniform distribution of term frequencyNormalizationH2
: term frequency density inversely related to lengthNormalizationH3
: term frequency normalization provided by Dirichlet priorNormalizationZ
: term frequency normalization provided by a Zipfian relationNormalization.NoNormalization
: no second normalization
Note that qtf, the multiplicity of term-occurrence in the query, is not handled by this implementation.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.similarities.Similarity
Similarity.SimScorer, Similarity.SimWeight
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AfterEffect
The first normalization of the information content.protected final BasicModel
The basic model for information content.protected final Normalization
The term frequency normalization.Fields inherited from class org.apache.lucene.search.similarities.SimilarityBase
discountOverlaps
-
Constructor Summary
ConstructorsConstructorDescriptionDFRSimilarity
(BasicModel basicModel, AfterEffect afterEffect, Normalization normalization) Creates DFRSimilarity from the three components. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
explain
(Explanation expl, BasicStats stats, int doc, float freq, float docLen) Subclasses should implement this method to explain the score.Returns the first normalizationReturns the basic model of information contentReturns the second normalizationprotected float
score
(BasicStats stats, float freq, float docLen) Scores the documentdoc
.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, decodeNormValue, encodeNormValue, explain, fillBasicStats, getDiscountOverlaps, log2, newStats, setDiscountOverlaps, simScorer
Methods inherited from class org.apache.lucene.search.similarities.Similarity
coord, queryNorm
-
Field Details
-
basicModel
The basic model for information content. -
afterEffect
The first normalization of the information content. -
normalization
The term frequency normalization.
-
-
Constructor Details
-
DFRSimilarity
Creates DFRSimilarity from the three components.Note that
null
values are not allowed: if you want no normalization or after-effect, instead passNormalization.NoNormalization
orAfterEffect.NoAfterEffect
respectively.- Parameters:
basicModel
- Basic model of information contentafterEffect
- First normalization of information gainnormalization
- Second (length) normalization
-
-
Method Details
-
score
Description copied from class:SimilarityBase
Scores the documentdoc
.Subclasses must apply their scoring formula in this class.
- Specified by:
score
in classSimilarityBase
- Parameters:
stats
- the corpus level statistics.freq
- the term frequency.docLen
- the document length.- Returns:
- the score.
-
explain
Description copied from class:SimilarityBase
Subclasses should implement this method to explain the score.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.
- Overrides:
explain
in classSimilarityBase
- Parameters:
expl
- the explanation to extend with details.stats
- the corpus level statistics.doc
- the document id.freq
- the term frequency.docLen
- the document length.
-
toString
Description copied from class:SimilarityBase
Subclasses must override this method to return the name of the Similarity and preferably the values of parameters (if any) as well.- Specified by:
toString
in classSimilarityBase
-
getBasicModel
Returns the basic model of information content -
getAfterEffect
Returns the first normalization -
getNormalization
Returns the second normalization
-