public abstract class LMSimilarity extends SimilarityBase
LMSimilarity.LMStats
, which defines a new statistic, the probability that
the collection language model generates the current term;LMSimilarity.CollectionModel
, which is a strategy interface for object that
compute the collection language model p(w|C)
;LMSimilarity.DefaultCollectionModel
, an implementation of the former, that
computes the term probability as the number of occurrences of the term in the
collection, divided by the total number of tokens.Modifier and Type | Class and Description |
---|---|
static interface |
LMSimilarity.CollectionModel
A strategy for computing the collection language model.
|
static class |
LMSimilarity.DefaultCollectionModel
Models
p(w|C) as the number of occurrences of the term in the
collection, divided by the total number of tokens + 1 . |
static class |
LMSimilarity.LMStats
Stores the collection distribution of the current term.
|
Similarity.SimScorer, Similarity.SimWeight
Modifier and Type | Field and Description |
---|---|
protected LMSimilarity.CollectionModel |
collectionModel
The collection model.
|
discountOverlaps
Constructor and Description |
---|
LMSimilarity()
Creates a new instance with the default collection language model.
|
LMSimilarity(LMSimilarity.CollectionModel collectionModel)
Creates a new instance with the specified collection language model.
|
Modifier and Type | Method and Description |
---|---|
protected void |
explain(Explanation expl,
BasicStats stats,
int doc,
float freq,
float docLen)
Subclasses should implement this method to explain the score.
|
protected void |
fillBasicStats(BasicStats stats,
CollectionStatistics collectionStats,
TermStatistics termStats)
Computes the collection probability of the current term in addition to the
usual statistics.
|
abstract String |
getName()
Returns the name of the LM method.
|
protected BasicStats |
newStats(String field,
float queryBoost)
Factory method to return a custom stats object
|
String |
toString()
Returns the name of the LM method.
|
computeNorm, computeWeight, decodeNormValue, encodeNormValue, explain, getDiscountOverlaps, log2, score, setDiscountOverlaps, simScorer
coord, queryNorm
protected final LMSimilarity.CollectionModel collectionModel
public LMSimilarity(LMSimilarity.CollectionModel collectionModel)
public LMSimilarity()
protected BasicStats newStats(String field, float queryBoost)
SimilarityBase
newStats
in class SimilarityBase
protected void fillBasicStats(BasicStats stats, CollectionStatistics collectionStats, TermStatistics termStats)
fillBasicStats
in class SimilarityBase
protected void explain(Explanation expl, BasicStats stats, int doc, float freq, float 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
expl
- the explanation to extend with details.stats
- the corpus level statistics.doc
- the document id.freq
- the term frequency.docLen
- the document length.public abstract String getName()
Used in toString()
public String toString()
toString
in class SimilarityBase
getName()
,
LMSimilarity.CollectionModel.getName()
,
LMSimilarity.DefaultCollectionModel
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.