public class TfIdfScorer extends AbstractWeightedScorer implements DelegatingScorer
There are a number of incarnations with small variations of the formula itself. Here, the weight assigned to a term which appears in f documents out of a collection of N documents w.r.t. to a document of length l in which the term appears c times is
This class uses a CounterCollectionVisitor
and related classes to take into consideration only terms that are actually involved
in the current document.
index2WeightdocumentIterator, indexIterator| Constructor and Description |
|---|
TfIdfScorer() |
| Modifier and Type | Method and Description |
|---|---|
TfIdfScorer |
copy() |
double |
score()
Computes a score by calling
Scorer.score(Index) for
each index in the current document iterator, and adding the weighted results. |
double |
score(Index index)
Returns a score for the current document of the last document iterator
given to
Scorer.wrap(DocumentIterator), but
considering only a given index (optional operation). |
boolean |
usesIntervals()
Whether this scorer uses intervals.
|
void |
wrap(DocumentIterator d)
Wraps the given document iterator.
|
getWeights, setWeightsnextDocumentclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetWeights, nextDocument, setWeightspublic TfIdfScorer copy()
copy in interface Scorercopy in interface FlyweightPrototype<Scorer>public double score()
throws IOException
AbstractWeightedScorerScorer.score(Index) for
each index in the current document iterator, and adding the weighted results.score in interface Scorerscore in class AbstractWeightedScorerIOExceptionpublic double score(Index index)
ScorerScorer.wrap(DocumentIterator), but
considering only a given index (optional operation).public void wrap(DocumentIterator d) throws IOException
AbstractScorerThis method records internally the provided iterator.
wrap in interface Scorerwrap in class AbstractWeightedScorerd - the document iterator that will be used in subsequent calls to
Scorer.score() and Scorer.score(Index).IOExceptionpublic boolean usesIntervals()
ScorerThis method is essential when aggregating scorers,
because if several scores need intervals, a CachingDocumentIterator
will be necessary.
usesIntervals in interface Scorer