Scorer.cs :  » Search-Engines » dotLucene » Lucene » Net » Search » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Search Engines » dotLucene 
dotLucene » Lucene » Net » Search » Scorer.cs
/*
 * Copyright 2004 The Apache Software Foundation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;

namespace Lucene.Net.Search{
  
  /// <summary>Expert: Common scoring functionality for different types of queries.
  /// <br>A <code>Scorer</code> either iterates over documents matching a query,
  /// or provides an explanation of the score for a query for a given document.
  /// <br>Document scores are computed using a given <code>Similarity</code> implementation.
  /// </summary>
  public abstract class Scorer
  {
    private Similarity similarity;
    
    /// <summary>Constructs a Scorer.</summary>
    /// <param name="similarity">The <code>Similarity</code> implementation used by this scorer.
    /// </param>
    protected internal Scorer(Similarity similarity)
    {
      this.similarity = similarity;
    }
    
    /// <summary>Returns the Similarity implementation used by this scorer. </summary>
    public virtual Similarity GetSimilarity()
    {
      return this.similarity;
    }
    
    /// <summary>Scores and collects all matching documents.</summary>
    /// <param name="hc">The collector to which all matching documents are passed through
    /// {@link HitCollector#Collect(int, float)}.
    /// <br>When this method is used the {@link #Explain(int)} method should not be used.
    /// </param>
    public virtual void  Score(HitCollector hc)
    {
      while (Next())
      {
        hc.Collect(Doc(), Score());
      }
    }
    
    /// <summary>Expert: Collects matching documents in a range.  Hook for optimization.
    /// Note that {@link #Next()} must be called once before this method is called
    /// for the first time.
    /// </summary>
    /// <param name="hc">The collector to which all matching documents are passed through
    /// {@link HitCollector#Collect(int, float)}.
    /// </param>
    /// <param name="max">Do not score documents past this.
    /// </param>
    /// <returns> true if more matching documents may remain.
    /// </returns>
    protected internal virtual bool Score(HitCollector hc, int max)
    {
      while (Doc() < max)
      {
        hc.Collect(Doc(), Score());
        if (!Next())
          return false;
      }
      return true;
    }
    
    /// <summary>Advances to the next document matching the query.</summary>
    /// <returns> true iff there is another document matching the query.
    /// <br>When this method is used the {@link #Explain(int)} method should not be used.
    /// </returns>
    public abstract bool Next();
    
    /// <summary>Returns the current document number matching the query.
    /// Initially invalid, until {@link #Next()} is called the first time.
    /// </summary>
    public abstract int Doc();
    
    /// <summary>Returns the score of the current document matching the query.
    /// Initially invalid, until {@link #Next()} or {@link #SkipTo(int)}
    /// is called the first time.
    /// </summary>
    public abstract float Score();
    
    /// <summary>Skips to the first match beyond the current whose document number is
    /// greater than or equal to a given target.
    /// <br>When this method is used the {@link #Explain(int)} method should not be used.
    /// </summary>
    /// <param name="target">The target document number.
    /// </param>
    /// <returns> true iff there is such a match.
    /// <p>Behaves as if written: <pre>
    /// boolean skipTo(int target) {
    /// do {
    /// if (!next())
    /// return false;
    /// } while (target > doc());
    /// return true;
    /// }
    /// </pre>Most implementations are considerably more efficient than that.
    /// </returns>
    public abstract bool SkipTo(int target);
    
    /// <summary>Returns an explanation of the score for a document.
    /// <br>When this method is used, the {@link #Next()}, {@link #SkipTo(int)} and
    /// {@link #Score(HitCollector)} methods should not be used.
    /// </summary>
    /// <param name="doc">The document number for the explanation.
    /// </param>
    public abstract Explanation Explain(int doc);
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.