~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/Scorer.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*------------------------------------------------------------------------------
 
2
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
 
3
 
4
* Distributable under the terms of either the Apache License (Version 2.0) or 
 
5
* the GNU Lesser General Public License, as specified in the COPYING file.
 
6
------------------------------------------------------------------------------*/
 
7
#ifndef _lucene_search_Scorer_
 
8
#define _lucene_search_Scorer_
 
9
 
 
10
CL_CLASS_DEF(search,Similarity)
 
11
CL_CLASS_DEF(search,HitCollector)
 
12
CL_CLASS_DEF(search,Explanation)
 
13
 
 
14
CL_NS_DEF(search)
 
15
 
 
16
/**
 
17
* Expert: Common scoring functionality for different types of queries.
 
18
*
 
19
* <p>
 
20
* A <code>Scorer</code> either iterates over documents matching a
 
21
* query in increasing order of doc Id, or provides an explanation of
 
22
* the score for a query for a given document.
 
23
* </p>
 
24
* <p>
 
25
* Document scores are computed using a given <code>Similarity</code>
 
26
* implementation.
 
27
* </p>
 
28
* @see BooleanQuery#setAllowDocsOutOfOrder
 
29
*/
 
30
class CLUCENE_EXPORT Scorer {
 
31
private:
 
32
        Similarity* similarity;
 
33
protected:
 
34
        /** Constructs a Scorer.
 
35
        * @param similarity The <code>Similarity</code> implementation used by this scorer.
 
36
        */
 
37
        Scorer(Similarity* _similarity);
 
38
 
 
39
public:
 
40
        virtual ~Scorer();
 
41
 
 
42
        /** Returns the Similarity implementation used by this scorer. */
 
43
        Similarity* getSimilarity()  const;
 
44
 
 
45
        /** Scores and collects all matching documents.
 
46
        * @param hc The collector to which all matching documents are passed through
 
47
        * {@link HitCollector#collect(int, float)}.
 
48
        * <br>When this method is used the {@link #explain(int)} method should not be used.
 
49
        */
 
50
        virtual void score(HitCollector* hc) ;
 
51
 
 
52
        /** Expert: Collects matching documents in a range.  Hook for optimization.
 
53
        * Note that {@link #next()} must be called once before this method is called
 
54
        * for the first time.
 
55
        * @param hc The collector to which all matching documents are passed through
 
56
        * {@link HitCollector#collect(int, float)}.
 
57
        * @param max Do not score documents past this.
 
58
        * @return true if more matching documents may remain.
 
59
        */
 
60
        virtual bool score( HitCollector* results, const int32_t maxDoc );
 
61
 
 
62
        /**
 
63
        * Advances to the document matching this Scorer with the lowest doc Id
 
64
        * greater than the current value of {@link #doc()} (or to the matching
 
65
        * document with the lowest doc Id if next has never been called on
 
66
        * this Scorer).
 
67
        *
 
68
        * <p>
 
69
        * When this method is used the {@link #explain(int)} method should not
 
70
        * be used.
 
71
        * </p>
 
72
        *
 
73
        * @return true iff there is another document matching the query.
 
74
        * @see BooleanQuery#setAllowDocsOutOfOrder
 
75
        */
 
76
        virtual bool next() = 0;
 
77
 
 
78
        /** Returns the current document number matching the query.
 
79
        * Initially invalid, until {@link #next()} is called the first time.
 
80
        */
 
81
        virtual int32_t doc() const = 0;
 
82
 
 
83
        /** Returns the score of the current document matching the query.
 
84
        * Initially invalid, until {@link #next()} or {@link #skipTo(int)}
 
85
        * is called the first time.
 
86
        */
 
87
        virtual float_t score() = 0;
 
88
 
 
89
        /**
 
90
        * Skips to the document matching this Scorer with the lowest doc Id
 
91
        * greater than or equal to a given target.
 
92
        *
 
93
        * <p>
 
94
        * The behavior of this method is undefined if the target specified is
 
95
        * less than or equal to the current value of {@link #doc()}.
 
96
        * <p>
 
97
        * Behaves as if written:
 
98
        * <pre>
 
99
        *   boolean skipTo(int target) {
 
100
        *     do {
 
101
        *       if (!next())
 
102
        *            return false;
 
103
        *     } while (target > doc());
 
104
        *     return true;
 
105
        *   }
 
106
        * </pre>
 
107
        * Most implementations are considerably more efficient than that.
 
108
        * </p>
 
109
        *
 
110
        * <p>
 
111
        * When this method is used the {@link #explain(int)} method should not
 
112
        * be used.
 
113
        * </p>
 
114
        *
 
115
        * @param target The target document number.
 
116
        * @return true iff there is such a match.
 
117
        * @see BooleanQuery#setAllowDocsOutOfOrder
 
118
        */
 
119
        virtual bool skipTo(int32_t target) = 0;
 
120
 
 
121
        /** Returns an explanation of the score for a document.
 
122
        * <br>When this method is used, the {@link #next()}, {@link #skipTo(int)} and
 
123
        * {@link #score(HitCollector)} methods should not be used.
 
124
        * @param doc The document number for the explanation.
 
125
        */
 
126
        virtual Explanation* explain(int32_t doc) = 0;
 
127
 
 
128
        /** Returns a string which explains the object */
 
129
        virtual TCHAR* toString() = 0;
 
130
 
 
131
        static bool sort(const Scorer* elem1, const Scorer* elem2);
 
132
};
 
133
CL_NS_END
 
134
#endif