Class BM25Similarity.BM25Scorer
- java.lang.Object
-
- org.apache.lucene.search.similarities.Similarity.SimScorer
-
- org.apache.lucene.search.similarities.BM25Similarity.BM25Scorer
-
- Enclosing class:
- BM25Similarity
private static class BM25Similarity.BM25Scorer extends Similarity.SimScorer
Collection statistics for the BM25 model.
-
-
Field Summary
Fields Modifier and Type Field Description private floatavgdlThe average document length.private floatbb value for length normalization impactprivate floatboostquery boostprivate float[]cacheprecomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl)private ExplanationidfBM25's idfprivate floatk1k1 value for scale factorprivate floatweightweight (idf * boost)
-
Constructor Summary
Constructors Constructor Description BM25Scorer(float boost, float k1, float b, Explanation idf, float avgdl, float[] cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Explanationexplain(Explanation freq, long encodedNorm)Explain the score for a single documentprivate java.util.List<Explanation>explainConstantFactors()private ExplanationexplainTF(Explanation freq, long norm)floatscore(float freq, long encodedNorm)Score a single document.
-
-
-
Field Detail
-
boost
private final float boost
query boost
-
k1
private final float k1
k1 value for scale factor
-
b
private final float b
b value for length normalization impact
-
idf
private final Explanation idf
BM25's idf
-
avgdl
private final float avgdl
The average document length.
-
cache
private final float[] cache
precomputed norm[256] with k1 * ((1 - b) + b * dl / avgdl)
-
weight
private final float weight
weight (idf * boost)
-
-
Constructor Detail
-
BM25Scorer
BM25Scorer(float boost, float k1, float b, Explanation idf, float avgdl, float[] cache)
-
-
Method Detail
-
score
public float score(float freq, long encodedNorm)Description copied from class:Similarity.SimScorerScore a single document.freqis the document-term sloppy frequency and must be finite and positive.normis the encoded normalization factor as computed bySimilarity.computeNorm(FieldInvertState)at index time, or1if norms are disabled.normis never0.Score must not decrease when
freqincreases, ie. iffreq1 > freq2, thenscore(freq1, norm) >= score(freq2, norm)for any value ofnormthat may be produced bySimilarity.computeNorm(FieldInvertState).Score must not increase when the unsigned
normincreases, ie. ifLong.compareUnsigned(norm1, norm2) > 0thenscore(freq, norm1) <= score(freq, norm2)for any legalfreq.As a consequence, the maximum score that this scorer can produce is bound by
score(Float.MAX_VALUE, 1).- Specified by:
scorein classSimilarity.SimScorer- Parameters:
freq- sloppy term frequency, must be finite and positiveencodedNorm- encoded normalization factor or1if norms are disabled- Returns:
- document's score
-
explain
public Explanation explain(Explanation freq, long encodedNorm)
Description copied from class:Similarity.SimScorerExplain the score for a single document- Overrides:
explainin classSimilarity.SimScorer- Parameters:
freq- Explanation of how the sloppy term frequency was computedencodedNorm- encoded normalization factor, as returned bySimilarity.computeNorm(org.apache.lucene.index.FieldInvertState), or1if norms are disabled- Returns:
- document's score
-
explainTF
private Explanation explainTF(Explanation freq, long norm)
-
explainConstantFactors
private java.util.List<Explanation> explainConstantFactors()
-
-