Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
IScorer.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. 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 using System.IO;
19 using Lucene.Net.Analysis;
20 
21 namespace Lucene.Net.Search.Highlight
22 {
23  /// <summary> Adds to the score for a fragment based on its tokens</summary>
24  public interface IScorer
25  {
26  /// <summary>
27  /// Called to init the Scorer with a {@link TokenStream}. You can grab references to
28  /// the attributes you are interested in here and access them from {@link #getTokenScore()}.
29  /// </summary>
30  /// <param name="tokenStream">the {@link TokenStream} that will be scored.</param>
31  /// <returns>
32  /// either a {@link TokenStream} that the Highlighter should continue using (eg
33  /// if you read the tokenSream in this method) or null to continue
34  /// using the same {@link TokenStream} that was passed in.
35  /// </returns>
36  /// <exception cref="IOException"></exception>
37  ///
38  TokenStream Init(TokenStream tokenStream);
39 
40  /// <summary>
41  /// Called when a new fragment is started for consideration.
42  /// </summary>
43  /// <param name="newFragment">the fragment that will be scored next</param>
44  void StartFragment(TextFragment newFragment);
45 
46  /// <summary>
47  /// Called for each token in the current fragment. The {@link Highlighter} will
48  /// increment the {@link TokenStream} passed to init on every call.
49  /// </summary>
50  /// <returns>a score which is passed to the {@link Highlighter} class to influence the
51  /// mark-up of the text (this return value is NOT used to score the
52  /// fragment)</returns>
53  float GetTokenScore();
54 
55  ///<summary>
56  /// Called when the {@link Highlighter} has no more tokens for the current fragment -
57  /// the Scorer returns the weighting it has derived for the most recent
58  /// fragment, typically based on the results of {@link #getTokenScore()}.
59  /// </summary>
60  float FragmentScore { get; }
61  }
62 }