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

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/PhraseQuery.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_PhraseQuery_
 
8
#define _lucene_search_PhraseQuery_
 
9
 
 
10
#include "Query.h"
 
11
CL_CLASS_DEF(index,Term)
 
12
CL_CLASS_DEF(search,Scorer)
 
13
#include "CLucene/util/Array.h"
 
14
#include "CLucene/util/VoidList.h"
 
15
 
 
16
CL_NS_DEF(search)
 
17
        /** A Query that matches documents containing a particular sequence of terms.
 
18
        * A PhraseQuery is built by QueryParser for input like <code>"new york"</code>.
 
19
        *
 
20
        * <p>This query may be combined with other terms or queries with a {@link BooleanQuery}.
 
21
        */
 
22
        class CLUCENE_EXPORT PhraseQuery: public Query {
 
23
        private:
 
24
                const TCHAR* field;
 
25
                CL_NS(util)::CLVector<CL_NS(index)::Term*>* terms;
 
26
                CL_NS(util)::CLVector<int32_t,CL_NS(util)::Deletor::DummyInt32>* positions;
 
27
                int32_t slop;
 
28
 
 
29
        friend class PhraseWeight;
 
30
        protected:
 
31
                Weight* _createWeight(Searcher* searcher);
 
32
                PhraseQuery(const PhraseQuery& clone);
 
33
        public:
 
34
                /** Constructs an empty phrase query. */
 
35
        PhraseQuery();
 
36
                virtual ~PhraseQuery();
 
37
 
 
38
                /** Sets the number of other words permitted between words in query phrase.
 
39
                If zero, then this is an exact phrase search.  For larger values this works
 
40
                like a <code>WITHIN</code> or <code>NEAR</code> operator.
 
41
 
 
42
                <p>The slop is in fact an edit-distance, where the units correspond to
 
43
                moves of terms in the query phrase out of position.  For example, to switch
 
44
                the order of two words requires two moves (the first move places the words
 
45
                atop one another), so to permit re-orderings of phrases, the slop must be
 
46
                at least two.
 
47
 
 
48
                <p>More exact matches are scored higher than sloppier matches, thus search
 
49
                results are sorted by exactness.
 
50
 
 
51
                <p>The slop is zero by default, requiring exact matches.*/
 
52
        void setSlop(const int32_t s);
 
53
 
 
54
                /** Returns the slop.  See setSlop(). */
 
55
        int32_t getSlop() const;
 
56
 
 
57
                /**
 
58
                * Adds a term to the end of the query phrase.
 
59
                * The relative position of the term is the one immediately after the last term added.
 
60
                */
 
61
        void add(CL_NS(index)::Term* term);
 
62
 
 
63
                /**
 
64
                * Adds a term to the end of the query phrase.
 
65
                * The relative position of the term within the phrase is specified explicitly.
 
66
                * This allows e.g. phrases with more than one term at the same position
 
67
                * or phrases with gaps (e.g. in connection with stopwords).
 
68
                *
 
69
                * @param term
 
70
                * @param position
 
71
                */
 
72
                void add(CL_NS(index)::Term* term, int32_t position);
 
73
 
 
74
                /** Returns the set of terms in this phrase. */
 
75
        CL_NS(index)::Term** getTerms() const;
 
76
 
 
77
                /**
 
78
                * Returns the relative positions of terms in this phrase.
 
79
                */
 
80
                void getPositions(CL_NS(util)::ValueArray<int32_t>& result) const;
 
81
 
 
82
                //Returns the sum of squared weights
 
83
    float_t sumOfSquaredWeights(Searcher* searcher);
 
84
 
 
85
                //Normalizes the Weight
 
86
    void normalize(const float_t norm);
 
87
 
 
88
    Scorer* scorer(CL_NS(index)::IndexReader* reader);
 
89
 
 
90
    const TCHAR* getFieldName() const;
 
91
 
 
92
                /** Prints a user-readable version of this query. */
 
93
    TCHAR* toString(const TCHAR* f) const;
 
94
 
 
95
                Query* clone() const;
 
96
                bool equals(Query *) const;
 
97
 
 
98
                size_t hashCode() const;
 
99
 
 
100
                const char* getObjectName() const;
 
101
                static const char* getClassName();
 
102
 
 
103
        /** Expert: adds all terms occurring in this query to the terms set. */
 
104
        void extractTerms( TermSet * termset ) const;
 
105
        };
 
106
CL_NS_END
 
107
#endif