Interface Scorer
-
- All Known Implementing Classes:
QueryScorer
,QueryTermScorer
public interface Scorer
A Scorer is responsible for scoring a stream of tokens. These token scores can then be used to computeTextFragment
scores.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description float
getFragmentScore()
Called when theHighlighter
has no more tokens for the current fragment - the Scorer returns the weighting it has derived for the most recent fragment, typically based on the results ofgetTokenScore()
.float
getTokenScore()
Called for each token in the current fragment.TokenStream
init(TokenStream tokenStream)
Called to init the Scorer with aTokenStream
.void
startFragment(TextFragment newFragment)
Called when a new fragment is started for consideration.
-
-
-
Method Detail
-
init
TokenStream init(TokenStream tokenStream) throws java.io.IOException
Called to init the Scorer with aTokenStream
. You can grab references to the attributes you are interested in here and access them fromgetTokenScore()
.- Parameters:
tokenStream
- theTokenStream
that will be scored.- Returns:
- either a
TokenStream
that the Highlighter should continue using (eg if you read the tokenSream in this method) or null to continue using the sameTokenStream
that was passed in. - Throws:
java.io.IOException
- If there is a low-level I/O error
-
startFragment
void startFragment(TextFragment newFragment)
Called when a new fragment is started for consideration.- Parameters:
newFragment
- the fragment that will be scored next
-
getTokenScore
float getTokenScore()
Called for each token in the current fragment. TheHighlighter
will increment theTokenStream
passed to init on every call.- Returns:
- a score which is passed to the
Highlighter
class to influence the mark-up of the text (this return value is NOT used to score the fragment)
-
getFragmentScore
float getFragmentScore()
Called when theHighlighter
has no more tokens for the current fragment - the Scorer returns the weighting it has derived for the most recent fragment, typically based on the results ofgetTokenScore()
.
-
-