summaryrefslogtreecommitdiff
path: root/3rdparty/clucene/src/CLucene/search/Scorer.h
blob: 0d1d4355a49273b2c8d19dc549ca21d6ad4b71e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#ifndef _lucene_search_Scorer_
#define _lucene_search_Scorer_

#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif

#include "Similarity.h"
#include "SearchHeader.h"
#include "Explanation.h"

CL_NS_DEF(search)
   /** Expert: Implements scoring for a class of queries. */
class Scorer: LUCENE_BASE {
   private:
      Similarity* similarity;
   protected:
      /** Constructs a Scorer. */
      Scorer(Similarity* similarity) {
         this->similarity = similarity;
      }
	public:
		virtual ~Scorer(){
		}

      /** Returns the Similarity implementation used by this scorer. */
      Similarity* getSimilarity()  const{
         return this->similarity;
      }

      /** Scores all documents and passes them to a collector. */
      void score(HitCollector* hc) {
         while (next()) {
            hc->collect(doc(), score());
         }
      }

      /** Advance to the next document matching the query.  Returns true iff there
         * is another match. */
      virtual bool next() = 0;

      /** Returns the current document number.  Initially invalid, until {@link
         * #next()} is called the first time. */
      virtual int32_t doc() const = 0;

      /** Returns the score of the current document.  Initially invalid, until
         * {@link #next()} is called the first time. */
      virtual qreal score() = 0;

      /** Skips to the first match beyond the current whose document number is
         * greater than or equal to <i>target</i>. <p>Returns true iff there is such
         * a match.  <p>Behaves as if written: <pre>
         *   boolean skipTo(int32_t target) {
         *     do {
         *       if (!next())
         * 	     return false;
         *     } while (target > doc());
         *     return true;
         *   }
         * </pre>
         * Most implementations are considerably more efficient than that.
         */
      virtual bool skipTo(int32_t target) = 0;

      /** Returns an explanation of the score for <code>doc</code>. */
      virtual void explain(int32_t doc, Explanation* ret) = 0;

	  
      /** Returns an string which explains the object */
      virtual TCHAR* toString() = 0;

    };
CL_NS_END
#endif