public class LMDirichletSimilarity extends LMSimilarity
The formula as defined the paper assigns a negative score to documents that
contain the term, but with fewer occurrences than predicted by the collection
language model. The Lucene implementation returns 0
for such
documents.
LMSimilarity.CollectionModel, LMSimilarity.DefaultCollectionModel, LMSimilarity.LMStats
Similarity.SimScorer
collectionModel
discountOverlaps
Constructor and Description |
---|
LMDirichletSimilarity()
Instantiates the similarity with the default μ value of 2000.
|
LMDirichletSimilarity(float mu)
Instantiates the similarity with the provided μ parameter.
|
LMDirichletSimilarity(LMSimilarity.CollectionModel collectionModel)
Instantiates the similarity with the default μ value of 2000.
|
LMDirichletSimilarity(LMSimilarity.CollectionModel collectionModel,
float mu)
Instantiates the similarity with the provided μ parameter.
|
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.
|
float |
getMu()
Returns the μ parameter.
|
String |
getName()
Returns the name of the LM method.
|
protected double |
score(BasicStats stats,
double freq,
double docLen)
Scores the document
doc . |
fillBasicStats, newStats, toString
computeNorm, getDiscountOverlaps, log2, scorer, setDiscountOverlaps
public LMDirichletSimilarity(LMSimilarity.CollectionModel collectionModel, float mu)
public LMDirichletSimilarity(float mu)
public LMDirichletSimilarity(LMSimilarity.CollectionModel collectionModel)
public LMDirichletSimilarity()
protected 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 LMSimilarity
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 float getMu()
public String getName()
LMSimilarity
Used in LMSimilarity.toString()
getName
in class LMSimilarity
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.