Module org.apache.lucene.core
Class TFIDFSimilarity.TFIDFScorer
java.lang.Object
org.apache.lucene.search.similarities.Similarity.SimScorer
org.apache.lucene.search.similarities.TFIDFSimilarity.TFIDFScorer
- Enclosing class:
TFIDFSimilarity
Collection statistics for the TF-IDF model. The only statistic of interest to this model is
idf.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final float
private final Explanation
The idf and its explanation(package private) final float[]
private final float
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexplain
(Explanation freq, long norm) Explain the score for a single documentprivate Explanation
explainScore
(Explanation freq, long encodedNorm, float[] normTable) float
score
(float freq, long norm) Score a single document.
-
Field Details
-
idf
The idf and its explanation -
boost
private final float boost -
queryWeight
private final float queryWeight -
normTable
final float[] normTable
-
-
Constructor Details
-
TFIDFScorer
-
-
Method Details
-
score
public float score(float freq, long norm) Description copied from class:Similarity.SimScorer
Score a single document.freq
is the document-term sloppy frequency and must be finite and positive.norm
is the encoded normalization factor as computed bySimilarity.computeNorm(FieldInvertState)
at index time, or1
if norms are disabled.norm
is never0
.Score must not decrease when
freq
increases, ie. iffreq1 > freq2
, thenscore(freq1, norm) >= score(freq2, norm)
for any value ofnorm
that may be produced bySimilarity.computeNorm(FieldInvertState)
.Score must not increase when the unsigned
norm
increases, ie. ifLong.compareUnsigned(norm1, norm2) > 0
thenscore(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:
score
in classSimilarity.SimScorer
- Parameters:
freq
- sloppy term frequency, must be finite and positivenorm
- encoded normalization factor or1
if norms are disabled- Returns:
- document's score
-
explain
Description copied from class:Similarity.SimScorer
Explain the score for a single document- Overrides:
explain
in classSimilarity.SimScorer
- Parameters:
freq
- Explanation of how the sloppy term frequency was computednorm
- encoded normalization factor, as returned bySimilarity.computeNorm(org.apache.lucene.index.FieldInvertState)
, or1
if norms are disabled- Returns:
- document's score
-
explainScore
-