|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Scorer
A wrapper for a DocumentIterator
returning scored document pointers.
Typically, a scorer may have one or more constructors, but all scorers should provide a constructor that takes only strings as arguments to make the instantiation from command-line or similar interfaces easier.
To be (re)used, a scorer must first wrap an
underlying DocumentIterator
. This
phase usually involves some preprocessing around properties of the document iterator to
be scored. After wrapping, calls to nextDocument()
and score()
(or possibly
score(Index)
) will return the next document pointer and
its score. Note that these methods are not usually idempotent, as they modify the state of the underlying iterator
(e.g., they consume intervals).
Scores returned by a scorer might depend on some weights associated with each index.
Optionally, a scorer might be a DelegatingScorer
.
Warning: implementations of this interface are not required
to be thread-safe, but they provide flyweight copies.
The copy()
method is strengthened so to return an object implementing this interface.
Method Summary | |
---|---|
Scorer |
copy()
|
Reference2DoubleMap<Index> |
getWeights()
Gets the weight map for this scorer (if applicable). |
int |
nextDocument()
Returns the next document provided by this scorer, or -1 if no more documents are available. |
double |
score()
Returns a score for the current document of the last document iterator given to wrap(DocumentIterator) . |
double |
score(Index index)
Returns a score for the current document of the last document iterator given to wrap(DocumentIterator) , but
considering only a given index (optional operation). |
boolean |
setWeights(Reference2DoubleMap<Index> index2Weight)
Sets the weight map for this scorer (if applicable). |
boolean |
usesIntervals()
Whether this scorer uses intervals. |
void |
wrap(DocumentIterator documentIterator)
Wraps a document iterator and prepares the internal state of this scorer to work with it. |
Method Detail |
---|
double score() throws IOException
wrap(DocumentIterator)
.
IOException
double score(Index index) throws IOException
wrap(DocumentIterator)
, but
considering only a given index (optional operation).
index
- the only index to be considered.
IOException
boolean setWeights(Reference2DoubleMap<Index> index2Weight)
The given map will be copied internally and can be used by the caller without affecting the scorer behaviour. Implementing classes should rescale the weights so that they have sum equal to one.
Indices not appearing in the map will have weight equal to 0.
index2Weight
- a map from indices to weights.
Reference2DoubleMap<Index> getWeights()
Returns a copy of the weight map of this scorer.
void wrap(DocumentIterator documentIterator) throws IOException
Subsequent calls to score()
and score(Index)
will use
d
to compute the score.
documentIterator
- the document iterator that will be used in subsequent calls to
score()
and score(Index)
.
IOException
boolean usesIntervals()
This method is essential when aggregating scorers,
because if several scores need intervals, a CachingDocumentIterator
will be necessary.
int nextDocument() throws IOException
IOException
Scorer copy()
copy
in interface FlyweightPrototype<Scorer>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |