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

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/Explanation.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_Explanation
 
8
#define _lucene_search_Explanation
 
9
 
 
10
#include "CLucene/util/VoidList.h"
 
11
 
 
12
CL_NS_DEF(search)
 
13
 
 
14
#define LUCENE_SEARCH_EXPLANATION_DESC_LEN 200
 
15
 
 
16
/** Expert: Describes the score computation for document and query. */
 
17
class CLUCENE_EXPORT Explanation {
 
18
private:
 
19
        float_t value;                                                                                                                  // the value of this node
 
20
        TCHAR description[LUCENE_SEARCH_EXPLANATION_DESC_LEN];                                  // what it represents
 
21
        CL_NS(util)::CLArrayList<Explanation*,
 
22
                CL_NS(util)::Deletor::Object<Explanation> >* details;                                   // sub-explanations
 
23
 
 
24
public:
 
25
        Explanation();
 
26
        Explanation(float_t _value, const TCHAR* _description);
 
27
        virtual ~Explanation();
 
28
 
 
29
        /**
 
30
        * Indicates whether or not this Explanation models a good match.
 
31
        *
 
32
        * <p>
 
33
        * By default, an Explanation represents a "match" if the value is positive.
 
34
        * </p>
 
35
        * @see #getValue
 
36
        */
 
37
        virtual bool isMatch() const;
 
38
 
 
39
        /** The value assigned to this explanation node. */
 
40
        float_t getValue() const;
 
41
        /** Sets the value assigned to this explanation node. */
 
42
        void setValue(const float_t value);
 
43
 
 
44
        /** A description of this explanation node. */
 
45
        const TCHAR* getDescription() const; ///<returns reference
 
46
        /** Sets the description of this explanation node. */
 
47
        void setDescription(const TCHAR* description);
 
48
protected:
 
49
        /**
 
50
        * A short one line summary which should contain all high level
 
51
        * information about this Explanation, without the "Details"
 
52
        */
 
53
        virtual TCHAR* getSummary();
 
54
 
 
55
public:
 
56
        Explanation(const Explanation& copy);
 
57
        void set(const Explanation& other);
 
58
        virtual Explanation* clone() const;
 
59
 
 
60
        /** The sub-nodes of this explanation node. 
 
61
        * @param ret this array of Explanations should be getDetailsLength()+1 in size. 
 
62
        *            The array will be null terminated.
 
63
        */
 
64
        void getDetails(Explanation** ret);
 
65
        size_t getDetailsLength() const;
 
66
 
 
67
        /** Watch out: no NULL reference check is made! Make sure i exists by not calling this function
 
68
        without calling getDetailsLength() first!
 
69
        */
 
70
        Explanation* getDetail(const size_t i);
 
71
 
 
72
        /** Adds a sub-node to this explanation node. */
 
73
        void addDetail(Explanation* detail);
 
74
 
 
75
        /** Render an explanation as text. */
 
76
        TCHAR* toString();
 
77
        TCHAR* toString(const int32_t depth);
 
78
 
 
79
        /** Render an explanation as HTML. */
 
80
        TCHAR* toHtml();
 
81
};
 
82
 
 
83
class CLUCENE_EXPORT ComplexExplanation : public Explanation {
 
84
private:
 
85
        bool match;
 
86
public:
 
87
        ComplexExplanation();
 
88
        ComplexExplanation(const ComplexExplanation& copy);
 
89
        ComplexExplanation(const bool _match, const float_t _value, const TCHAR* _description);
 
90
        virtual ~ComplexExplanation();
 
91
 
 
92
        /**
 
93
        * The match status of this explanation node.
 
94
        * @return May be null if match status is unknown
 
95
        */
 
96
        bool getMatch() const;
 
97
        /**
 
98
        * Sets the match status assigned to this explanation node.
 
99
        * @param match May be null if match status is unknown
 
100
        */
 
101
        void setMatch(const bool _match);
 
102
        /**
 
103
        * Indicates wether or not this Explanation models a good match.
 
104
        *
 
105
        * <p>
 
106
        * If the match statis is explicitly set (ie: not null) this method
 
107
        * uses it; otherwise it defers to the superclass.
 
108
        * </p>
 
109
        * @see #getMatch
 
110
        */
 
111
        bool isMatch() const;
 
112
 
 
113
        Explanation* clone() const;
 
114
 
 
115
protected:
 
116
        TCHAR* getSummary();
 
117
};
 
118
 
 
119
CL_NS_END
 
120
#endif