KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lucene > search > highlight > Scorer


1 package org.apache.lucene.search.highlight;
2 /**
3  * Copyright 2002-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import org.apache.lucene.analysis.Token;
19
20 /**
21  * Adds to the score for a fragment based on its tokens
22  * @author mark@searcharea.co.uk
23  */

24 public interface Scorer
25 {
26     /**
27      * called when a new fragment is started for consideration
28      * @param newFragment
29      */

30     public void startFragment(TextFragment newFragment);
31
32     /**
33      * Called for each token in the current fragment
34      * @param token The token to be scored
35      * @return a score which is passed to the Highlighter class to influence the mark-up of the text
36      * (this return value is NOT used to score the fragment)
37      */

38     public float getTokenScore(Token token);
39     
40
41     /**
42      * Called when the highlighter has no more tokens for the current fragment - the scorer returns
43      * the weighting it has derived for the most recent fragment, typically based on the tokens
44      * passed to getTokenScore().
45      *
46      */

47     public float getFragmentScore();
48
49 }
50
Popular Tags